8166931: Do not include classes which are unusable during run time in the classlist file

Added check to exclude classes found in the --patch-module list

Reviewed-by: jiangli, lfoltan, iklam
This commit is contained in:
Calvin Cheung 2016-10-18 16:15:03 -07:00
parent 3b1fe56bf5
commit c5dc50c03f
4 changed files with 161 additions and 6 deletions

View file

@ -5775,9 +5775,22 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream,
// Anonymous classes such as generated LambdaForm classes are also not included.
if (SystemDictionaryShared::is_sharing_possible(_loader_data) &&
_host_klass == NULL) {
oop class_loader = _loader_data->class_loader();
ResourceMark rm(THREAD);
classlist_file->print_cr("%s", _class_name->as_C_string());
classlist_file->flush();
// For the boot and platform class loaders, check if the class is not found in the
// java runtime image. Additional check for the boot class loader is if the class
// is not found in the boot loader's appended entries. This indicates that the class
// is not useable during run time, such as the ones found in the --patch-module entries,
// so it should not be included in the classlist file.
if (((class_loader == NULL && !ClassLoader::contains_append_entry(stream->source())) ||
SystemDictionary::is_platform_class_loader(class_loader)) &&
!ClassLoader::is_jrt(stream->source())) {
tty->print_cr("skip writing class %s from source %s to classlist file",
_class_name->as_C_string(), stream->source());
} else {
classlist_file->print_cr("%s", _class_name->as_C_string());
classlist_file->flush();
}
}
}
#endif