8167333: Invalid source path info might be used when creating ClassFileStream after CFLH transforms a shared classes in some cases
Summary: Use NULL as 'source' when there is no valid source path info.
Reviewed-by: iklam, dholmes, dsamersoff
--- a/hotspot/src/share/vm/classfile/klassFactory.cpp Tue Oct 18 16:09:34 2016 +0000
+++ b/hotspot/src/share/vm/classfile/klassFactory.cpp Mon Oct 10 20:50:33 2016 -0400
@@ -74,7 +74,7 @@
(SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
ClassFileStream* stream = new ClassFileStream(ptr,
end_ptr - ptr,
- ent->_name,
+ ent == NULL ? NULL : ent->_name,
ClassFileStream::verify);
ClassFileParser parser(stream,
class_name,
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Tue Oct 18 16:09:34 2016 +0000
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Mon Oct 10 20:50:33 2016 -0400
@@ -1234,7 +1234,7 @@
SharedClassPathEntry* ent =
(SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
if (!Universe::is_module_initialized()) {
- assert(ent->is_jrt(),
+ assert(ent != NULL && ent->is_jrt(),
"Loading non-bootstrap classes before the module system is initialized");
assert(class_loader.is_null(), "sanity");
return true;
@@ -1257,6 +1257,7 @@
}
if (class_loader.is_null()) {
+ assert(ent != NULL, "Shared class for NULL classloader must have valid SharedClassPathEntry");
// The NULL classloader can load archived class originated from the
// "modules" jimage and the -Xbootclasspath/a. For class from the
// "modules" jimage, the PackageEntry/ModuleEntry must be defined
--- a/hotspot/src/share/vm/memory/filemap.hpp Tue Oct 18 16:09:34 2016 +0000
+++ b/hotspot/src/share/vm/memory/filemap.hpp Mon Oct 10 20:50:33 2016 -0400
@@ -283,11 +283,15 @@
bool validate_classpath_entry_table();
static SharedClassPathEntry* shared_classpath(int index) {
+ if (index < 0) {
+ return NULL;
+ }
char* p = (char*)_classpath_entry_table;
p += _classpath_entry_size * index;
return (SharedClassPathEntry*)p;
}
static const char* shared_classpath_name(int index) {
+ assert(index >= 0, "Sanity");
return shared_classpath(index)->_name;
}