@@ -1270,31 +1270,33 @@ bool isHiddenClass(jvmtiEnv *jvmti, jclass clazz) {
12701270 return false ;
12711271}
12721272
1273- bool HotspotSupport::loadMethodIDsIfNeededImpl (jvmtiEnv *jvmti, JNIEnv *jni, jclass klass) {
1274- jobject cl = nullptr ;
1275- // Hidden/lambda classes can not unloaded, fallback to use jmethodIDs, so preload them.
1276- if (!isHiddenClass (jvmti, klass) &&
1277- jvmti->GetClassLoader (klass, &cl) == JVMTI_ERROR_NONE &&
1278- isSystemClassLoader (jni, cl)) {
1279- char * signature_ptr = nullptr ;
1280- if (jvmti->GetClassSignature (klass, &signature_ptr, nullptr ) == JVMTI_ERROR_NONE ) {
1281- // Lambda classes, even loaded by bootstrap class loader, can be unloaded,
1282- // fallback to jmethodID
1283- if (!isLambdaClass (signature_ptr)) {
1284- if (cl != nullptr ) {
1285- jni->DeleteLocalRef (cl);
1273+ bool HotspotSupport::loadMethodIDsIfNeededImpl (jvmtiEnv *jvmti, JNIEnv *jni, jclass klass, bool load_all) {
1274+ if (!load_all) {
1275+ jobject cl = nullptr ;
1276+ // Hidden/lambda classes can not unloaded, fallback to use jmethodIDs, so preload them.
1277+ if (!isHiddenClass (jvmti, klass) &&
1278+ jvmti->GetClassLoader (klass, &cl) == JVMTI_ERROR_NONE &&
1279+ isSystemClassLoader (jni, cl)) {
1280+ char * signature_ptr = nullptr ;
1281+ if (jvmti->GetClassSignature (klass, &signature_ptr, nullptr ) == JVMTI_ERROR_NONE ) {
1282+ // Lambda classes, even loaded by bootstrap class loader, can be unloaded,
1283+ // fallback to jmethodID
1284+ if (!isLambdaClass (signature_ptr)) {
1285+ if (cl != nullptr ) {
1286+ jni->DeleteLocalRef (cl);
1287+ }
1288+ jvmti->Deallocate ((unsigned char *)signature_ptr);
1289+ return false ;
12861290 }
1291+ }
1292+ if (signature_ptr != nullptr ) {
12871293 jvmti->Deallocate ((unsigned char *)signature_ptr);
1288- return false ;
12891294 }
12901295 }
1291- if (signature_ptr != nullptr ) {
1292- jvmti-> Deallocate (( unsigned char *)signature_ptr );
1296+ if (cl != nullptr ) {
1297+ jni-> DeleteLocalRef (cl );
12931298 }
12941299 }
1295- if (cl != nullptr ) {
1296- jni->DeleteLocalRef (cl);
1297- }
12981300 patchClassLoaderData (jni, klass);
12991301 return JVMSupport::loadMethodIDsImpl (jvmti, jni, klass);
13001302}
0 commit comments