Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/whitebox.cpp @ 10196:dc7db03f5aa2
8012337: Change Whitebox implementation to make absence of method in Whitebox.class not fatal
Reviewed-by: kvn, vlivanov
author | iignatyev |
---|---|
date | Thu, 25 Apr 2013 11:04:36 -0700 |
parents | 2a9d97b57920 |
children | 9ce110b1d14a |
comparison
equal
deleted
inserted
replaced
10195:e12c9b3740db | 10196:dc7db03f5aa2 |
---|---|
434 if (WhiteBoxAPI) { | 434 if (WhiteBoxAPI) { |
435 // Make sure that wbclass is loaded by the null classloader | 435 // Make sure that wbclass is loaded by the null classloader |
436 instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass()); | 436 instanceKlassHandle ikh = instanceKlassHandle(JNIHandles::resolve(wbclass)->klass()); |
437 Handle loader(ikh->class_loader()); | 437 Handle loader(ikh->class_loader()); |
438 if (loader.is_null()) { | 438 if (loader.is_null()) { |
439 ResourceMark rm; | |
439 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI | 440 ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI |
440 jint result = env->RegisterNatives(wbclass, methods, sizeof(methods)/sizeof(methods[0])); | 441 bool result = true; |
441 if (result == 0) { | 442 // one by one registration natives for exception catching |
443 jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string()); | |
444 for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) { | |
445 if (env->RegisterNatives(wbclass, methods + i, 1) != 0) { | |
446 result = false; | |
447 if (env->ExceptionCheck() && env->IsInstanceOf(env->ExceptionOccurred(), exceptionKlass)) { | |
448 // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native | |
449 // ignoring the exception | |
450 tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature); | |
451 env->ExceptionClear(); | |
452 } else { | |
453 // register is failed w/o exception or w/ unexpected exception | |
454 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); | |
455 env->UnregisterNatives(wbclass); | |
456 break; | |
457 } | |
458 } | |
459 } | |
460 | |
461 if (result) { | |
442 WhiteBox::set_used(); | 462 WhiteBox::set_used(); |
443 } | 463 } |
444 } | 464 } |
445 } | 465 } |
446 } | 466 } |