8167333: Invalid source path info might be used when creating ClassFileStream after CFLH transforms a shared classes in some cases

Use NULL as 'source' when there is no valid source path info.

Reviewed-by: iklam, dholmes, dsamersoff
This commit is contained in:
Jiangli Zhou 2016-10-10 20:50:33 -04:00
parent da45a98b46
commit 4d9fc9541d
3 changed files with 7 additions and 2 deletions

View file

@ -74,7 +74,7 @@ instanceKlassHandle KlassFactory::check_shared_class_file_load_hook(
(SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index); (SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
ClassFileStream* stream = new ClassFileStream(ptr, ClassFileStream* stream = new ClassFileStream(ptr,
end_ptr - ptr, end_ptr - ptr,
ent->_name, ent == NULL ? NULL : ent->_name,
ClassFileStream::verify); ClassFileStream::verify);
ClassFileParser parser(stream, ClassFileParser parser(stream,
class_name, class_name,

View file

@ -1234,7 +1234,7 @@ bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
SharedClassPathEntry* ent = SharedClassPathEntry* ent =
(SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index); (SharedClassPathEntry*)FileMapInfo::shared_classpath(path_index);
if (!Universe::is_module_initialized()) { 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"); "Loading non-bootstrap classes before the module system is initialized");
assert(class_loader.is_null(), "sanity"); assert(class_loader.is_null(), "sanity");
return true; return true;
@ -1257,6 +1257,7 @@ bool SystemDictionary::is_shared_class_visible(Symbol* class_name,
} }
if (class_loader.is_null()) { 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 // The NULL classloader can load archived class originated from the
// "modules" jimage and the -Xbootclasspath/a. For class from the // "modules" jimage and the -Xbootclasspath/a. For class from the
// "modules" jimage, the PackageEntry/ModuleEntry must be defined // "modules" jimage, the PackageEntry/ModuleEntry must be defined

View file

@ -283,11 +283,15 @@ public:
bool validate_classpath_entry_table(); bool validate_classpath_entry_table();
static SharedClassPathEntry* shared_classpath(int index) { static SharedClassPathEntry* shared_classpath(int index) {
if (index < 0) {
return NULL;
}
char* p = (char*)_classpath_entry_table; char* p = (char*)_classpath_entry_table;
p += _classpath_entry_size * index; p += _classpath_entry_size * index;
return (SharedClassPathEntry*)p; return (SharedClassPathEntry*)p;
} }
static const char* shared_classpath_name(int index) { static const char* shared_classpath_name(int index) {
assert(index >= 0, "Sanity");
return shared_classpath(index)->_name; return shared_classpath(index)->_name;
} }