src/share/vm/prims/whitebox.cpp

Print this page




 416       CC"()I",                                        (void*)&WB_GetCompileQueuesSize},
 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


 416       CC"()I",                                        (void*)&WB_GetCompileQueuesSize},
 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         ResourceMark rm;
 437         ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI
 438         bool result = true;
 439         //  one by one registration natives for exception catching
 440         jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string());
 441         for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) {
 442           if (env->RegisterNatives(wbclass, methods + i, 1) != 0) {
 443             result = false;
 444             if (env->ExceptionCheck() && env->IsInstanceOf(env->ExceptionOccurred(), exceptionKlass)) {
 445               // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native
 446               // ignoring the exception
 447               tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature);
 448               env->ExceptionClear();
 449             } else {
 450               // register is failed w/o exception or w/ unexpected exception
 451               tty->print_cr("Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered", methods[i].name, methods[i].signature);
 452               env->UnregisterNatives(wbclass);
 453               break;
 454             }
 455           }
 456         }
 457 
 458         if (result) {
 459           WhiteBox::set_used();
 460         }
 461       }
 462     }
 463   }
 464 JVM_END