mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 17:14:41 +02:00
8220095: Assertion failure when symlink (with different name) is used for lib/modules file
Removed confusing function ClassLoader::is_modules_image(char*) Reviewed-by: lfoltan, ccheung
This commit is contained in:
parent
26210b4566
commit
223e1c6e42
7 changed files with 111 additions and 15 deletions
|
@ -361,6 +361,8 @@ void ClassPathZipEntry::contents_do(void f(const char* name, void* context), voi
|
|||
}
|
||||
}
|
||||
|
||||
DEBUG_ONLY(ClassPathImageEntry* ClassPathImageEntry::_singleton = NULL;)
|
||||
|
||||
void ClassPathImageEntry::close_jimage() {
|
||||
if (_jimage != NULL) {
|
||||
(*JImageClose)(_jimage);
|
||||
|
@ -373,12 +375,17 @@ ClassPathImageEntry::ClassPathImageEntry(JImageFile* jimage, const char* name) :
|
|||
_jimage(jimage) {
|
||||
guarantee(jimage != NULL, "jimage file is null");
|
||||
guarantee(name != NULL, "jimage file name is null");
|
||||
assert(_singleton == NULL, "VM supports only one jimage");
|
||||
DEBUG_ONLY(_singleton = this);
|
||||
size_t len = strlen(name) + 1;
|
||||
_name = NEW_C_HEAP_ARRAY(const char, len, mtClass);
|
||||
strncpy((char *)_name, name, len);
|
||||
}
|
||||
|
||||
ClassPathImageEntry::~ClassPathImageEntry() {
|
||||
assert(_singleton == this, "must be");
|
||||
DEBUG_ONLY(_singleton = NULL);
|
||||
|
||||
if (_name != NULL) {
|
||||
FREE_C_HEAP_ARRAY(const char, _name);
|
||||
_name = NULL;
|
||||
|
@ -442,10 +449,12 @@ ClassFileStream* ClassPathImageEntry::open_stream(const char* name, TRAPS) {
|
|||
char* data = NEW_RESOURCE_ARRAY(char, size);
|
||||
(*JImageGetResource)(_jimage, location, data, size);
|
||||
// Resource allocated
|
||||
assert(this == (ClassPathImageEntry*)ClassLoader::get_jrt_entry(), "must be");
|
||||
return new ClassFileStream((u1*)data,
|
||||
(int)size,
|
||||
_name,
|
||||
ClassFileStream::verify);
|
||||
ClassFileStream::verify,
|
||||
true); // from_boot_loader_modules_image
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -459,7 +468,9 @@ JImageLocationRef ClassLoader::jimage_find_resource(JImageFile* jf,
|
|||
}
|
||||
|
||||
bool ClassPathImageEntry::is_modules_image() const {
|
||||
return ClassLoader::is_modules_image(name());
|
||||
assert(this == _singleton, "VM supports a single jimage");
|
||||
assert(this == (ClassPathImageEntry*)ClassLoader::get_jrt_entry(), "must be used for jrt entry");
|
||||
return true;
|
||||
}
|
||||
|
||||
#if INCLUDE_CDS
|
||||
|
@ -737,8 +748,8 @@ void ClassLoader::setup_boot_search_path(const char *class_path) {
|
|||
// Check for a jimage
|
||||
if (Arguments::has_jimage()) {
|
||||
assert(_jrt_entry == NULL, "should not setup bootstrap class search path twice");
|
||||
assert(new_entry != NULL && new_entry->is_modules_image(), "No java runtime image present");
|
||||
_jrt_entry = new_entry;
|
||||
assert(new_entry != NULL && new_entry->is_modules_image(), "No java runtime image present");
|
||||
assert(_jrt_entry->jimage() != NULL, "No java runtime image");
|
||||
}
|
||||
} else {
|
||||
|
@ -1499,7 +1510,7 @@ void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream
|
|||
}
|
||||
// for index 0 and the stream->source() is the modules image or has the jrt: protocol.
|
||||
// The class must be from the runtime modules image.
|
||||
if (i == 0 && (is_modules_image(src) || string_starts_with(src, "jrt:"))) {
|
||||
if (i == 0 && (stream->from_boot_loader_modules_image() || string_starts_with(src, "jrt:"))) {
|
||||
classpath_index = i;
|
||||
break;
|
||||
}
|
||||
|
@ -1515,7 +1526,7 @@ void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream
|
|||
// The shared path table is set up after module system initialization.
|
||||
// The path table contains no entry before that. Any classes loaded prior
|
||||
// to the setup of the shared path table must be from the modules image.
|
||||
assert(is_modules_image(src), "stream must be from modules image");
|
||||
assert(stream->from_boot_loader_modules_image(), "stream must be loaded by boot loader from modules image");
|
||||
assert(FileMapInfo::get_number_of_shared_paths() == 0, "shared path table must not have been setup");
|
||||
classpath_index = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue