mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
6755845: JVM_FindClassFromBoot triggers assertions
Fixes assertions caused by one jvm_entry calling another, solved by refactoring code and modified gamma test. Reviewed-by: dholmes, xlu
This commit is contained in:
parent
fe28b4f768
commit
3a72f5c241
7 changed files with 108 additions and 36 deletions
|
@ -628,6 +628,32 @@ JVM_ENTRY(void, JVM_ResolveClass(JNIEnv* env, jclass cls))
|
|||
if (PrintJVMWarnings) warning("JVM_ResolveClass not implemented");
|
||||
JVM_END
|
||||
|
||||
// Common implementation for JVM_FindClassFromBootLoader and
|
||||
// JVM_FindClassFromLoader
|
||||
static jclass jvm_find_class_from_class_loader(JNIEnv* env, const char* name,
|
||||
jboolean init, jobject loader,
|
||||
jboolean throwError, TRAPS) {
|
||||
// Java libraries should ensure that name is never null...
|
||||
if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) {
|
||||
// It's impossible to create this class; the name cannot fit
|
||||
// into the constant pool.
|
||||
if (throwError) {
|
||||
THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
|
||||
} else {
|
||||
THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
|
||||
}
|
||||
}
|
||||
symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL);
|
||||
Handle h_loader(THREAD, JNIHandles::resolve(loader));
|
||||
jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
|
||||
Handle(), throwError, THREAD);
|
||||
|
||||
if (TraceClassResolution && result != NULL) {
|
||||
trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Rationale behind JVM_FindClassFromBootLoader
|
||||
// a> JVM_FindClassFromClassLoader was never exported in the export tables.
|
||||
// b> because of (a) java.dll has a direct dependecy on the unexported
|
||||
|
@ -649,8 +675,8 @@ JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env,
|
|||
jboolean throwError))
|
||||
JVMWrapper3("JVM_FindClassFromBootLoader %s throw %s", name,
|
||||
throwError ? "error" : "exception");
|
||||
return JVM_FindClassFromClassLoader(env, name, JNI_FALSE,
|
||||
(jobject)NULL, throwError);
|
||||
return jvm_find_class_from_class_loader(env, name, JNI_FALSE,
|
||||
(jobject)NULL, throwError, THREAD);
|
||||
JVM_END
|
||||
|
||||
JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name,
|
||||
|
@ -658,26 +684,8 @@ JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name,
|
|||
jboolean throwError))
|
||||
JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name,
|
||||
throwError ? "error" : "exception");
|
||||
// Java libraries should ensure that name is never null...
|
||||
if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) {
|
||||
// It's impossible to create this class; the name cannot fit
|
||||
// into the constant pool.
|
||||
if (throwError) {
|
||||
THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
|
||||
} else {
|
||||
THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
|
||||
}
|
||||
}
|
||||
symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL);
|
||||
Handle h_loader(THREAD, JNIHandles::resolve(loader));
|
||||
jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
|
||||
Handle(), throwError, thread);
|
||||
|
||||
if (TraceClassResolution && result != NULL) {
|
||||
trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result)));
|
||||
}
|
||||
|
||||
return result;
|
||||
return jvm_find_class_from_class_loader(env, name, init, loader,
|
||||
throwError, THREAD);
|
||||
JVM_END
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue