mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8202758: SIGSEGV calling Class.forName(String,Boolean,ClassLoader) with mocked loader
Check that the unnamed module for a given ClassLoader is an instance of java.lang.Module. Reviewed-by: alanb, acorn, coleenp, dholmes, hseigel
This commit is contained in:
parent
fc1be4c573
commit
d623fc1bba
3 changed files with 114 additions and 3 deletions
|
@ -25,7 +25,7 @@
|
|||
#include "precompiled.hpp"
|
||||
#include "jni.h"
|
||||
#include "classfile/classLoaderData.inline.hpp"
|
||||
#include "classfile/javaClasses.hpp"
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/moduleEntry.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
|
@ -236,10 +236,17 @@ ModuleEntry* ModuleEntry::create_unnamed_module(ClassLoaderData* cld) {
|
|||
// The java.lang.Module for this loader's
|
||||
// corresponding unnamed module can be found in the java.lang.ClassLoader object.
|
||||
oop module = java_lang_ClassLoader::unnamedModule(cld->class_loader());
|
||||
|
||||
// Ensure that the unnamed module was correctly set when the class loader was constructed.
|
||||
// Guarantee will cause a recognizable crash if the user code has circumvented calling the ClassLoader constructor.
|
||||
ResourceMark rm;
|
||||
guarantee(java_lang_Module::is_instance(module),
|
||||
"The unnamed module for ClassLoader %s, is null or not an instance of java.lang.Module. The class loader has not been initialized correctly.",
|
||||
cld->loader_name());
|
||||
|
||||
ModuleEntry* unnamed_module = new_unnamed_module_entry(Handle(Thread::current(), module), cld);
|
||||
|
||||
// Store pointer to the ModuleEntry in the unnamed module's java.lang.Module
|
||||
// object.
|
||||
// Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
|
||||
java_lang_Module::set_module_entry(module, unnamed_module);
|
||||
|
||||
return unnamed_module;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue