417 {CC"testSetForceInlineMethod", 418 CC"(Ljava/lang/reflect/Method;Z)Z", (void*)&WB_TestSetForceInlineMethod}, 419 {CC"enqueueMethodForCompilation", 420 CC"(Ljava/lang/reflect/Method;I)Z", (void*)&WB_EnqueueMethodForCompilation}, 421 {CC"clearMethodState", 422 CC"(Ljava/lang/reflect/Method;)V", (void*)&WB_ClearMethodState}, 423 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, 424 {CC"fullGC", CC"()V", (void*)&WB_FullGC }, 425 }; 426 427 #undef CC 428 429 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) 430 { 431 if (WhiteBoxAPI) { 432 // Make sure that wbclass is loaded by the null classloader 433 instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass()); 434 Handle loader(ikh->class_loader()); 435 if (loader.is_null()) { 436 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI 437 jint result = env->RegisterNatives(wbclass, methods, sizeof(methods)/sizeof(methods[0])); 438 if (result == 0) { 439 WhiteBox::set_used(); 440 } 441 } 442 } 443 } 444 JVM_END | 417 {CC"testSetForceInlineMethod", 418 CC"(Ljava/lang/reflect/Method;Z)Z", (void*)&WB_TestSetForceInlineMethod}, 419 {CC"enqueueMethodForCompilation", 420 CC"(Ljava/lang/reflect/Method;I)Z", (void*)&WB_EnqueueMethodForCompilation}, 421 {CC"clearMethodState", 422 CC"(Ljava/lang/reflect/Method;)V", (void*)&WB_ClearMethodState}, 423 {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, 424 {CC"fullGC", CC"()V", (void*)&WB_FullGC }, 425 }; 426 427 #undef CC 428 429 JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) 430 { 431 if (WhiteBoxAPI) { 432 // Make sure that wbclass is loaded by the null classloader 433 instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass()); 434 Handle loader(ikh->class_loader()); 435 if (loader.is_null()) { 436 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI 437 bool result = true; 438 // one by one registration natives for exception catching 439 for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) { 440 if (env->RegisterNatives(wbclass, methods + i, 1) != 0) { 441 result &= false; 442 if (env->ExceptionCheck()) { 443 tty->print_cr("Warning: exception on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature); 444 env->ExceptionClear(); 445 result &= false; 446 } else { 447 // register is failed w/o exception 448 env->UnregisterNatives(wbclass); 449 result &= false; 450 break; 451 } 452 } 453 } 454 455 if (result) { 456 WhiteBox::set_used(); 457 } 458 } 459 } 460 } 461 JVM_END |