--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Oct 18 17:38:17 2016 -0400
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Oct 18 16:15:03 2016 -0700
@@ -5775,9 +5775,22 @@
// 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