8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending
Added JNI exception pending check in several files under src/share/vm/prims directory Reviewed-by: coleenp, minqi
This commit is contained in:
parent
a752b0b503
commit
afe8f1c904
@ -4348,8 +4348,23 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {
|
||||
|
||||
// Get needed field and method IDs
|
||||
directByteBufferConstructor = env->GetMethodID(directByteBufferClass, "<init>", "(JI)V");
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
directBufferSupportInitializeFailed = 1;
|
||||
return false;
|
||||
}
|
||||
directBufferAddressField = env->GetFieldID(bufferClass, "address", "J");
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
directBufferSupportInitializeFailed = 1;
|
||||
return false;
|
||||
}
|
||||
bufferCapacityField = env->GetFieldID(bufferClass, "capacity", "I");
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
directBufferSupportInitializeFailed = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((directByteBufferConstructor == NULL) ||
|
||||
(directBufferAddressField == NULL) ||
|
||||
|
@ -858,6 +858,11 @@ static inline void throw_new(JNIEnv *env, const char *ename) {
|
||||
strcpy(buf, "java/lang/");
|
||||
strcat(buf, ename);
|
||||
jclass cls = env->FindClass(buf);
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
tty->print_cr("Unsafe: cannot throw %s because FindClass has failed", buf);
|
||||
return;
|
||||
}
|
||||
char* msg = NULL;
|
||||
env->ThrowNew(cls, msg);
|
||||
}
|
||||
|
@ -316,9 +316,10 @@ WB_END
|
||||
|
||||
WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
int result = 0;
|
||||
CHECK_JNI_EXCEPTION_(env, result);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
int result = 0;
|
||||
nmethod* code;
|
||||
if (is_osr) {
|
||||
int bci = InvocationEntryBci;
|
||||
@ -344,6 +345,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
|
||||
@ -355,6 +357,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
if (is_osr) {
|
||||
@ -366,6 +369,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
return mh->queued_for_compilation();
|
||||
@ -373,6 +377,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, CompLevel_none);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
|
||||
return (code != NULL ? code->comp_level() : CompLevel_none);
|
||||
@ -380,6 +385,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION(env);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
if (is_osr) {
|
||||
mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox");
|
||||
@ -390,6 +396,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, InvocationEntryBci);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false);
|
||||
return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci);
|
||||
@ -397,6 +404,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
bool result = mh->dont_inline();
|
||||
mh->set_dont_inline(value == JNI_TRUE);
|
||||
@ -414,6 +422,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
bool result = mh->force_inline();
|
||||
mh->set_force_inline(value == JNI_TRUE);
|
||||
@ -422,6 +431,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
@ -430,6 +440,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION(env);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
MethodData* mdo = mh->method_data();
|
||||
@ -616,14 +627,18 @@ JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
|
||||
bool result = true;
|
||||
// one by one registration natives for exception catching
|
||||
jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string());
|
||||
CHECK_JNI_EXCEPTION(env);
|
||||
for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) {
|
||||
if (env->RegisterNatives(wbclass, methods + i, 1) != 0) {
|
||||
result = false;
|
||||
if (env->ExceptionCheck() && env->IsInstanceOf(env->ExceptionOccurred(), exceptionKlass)) {
|
||||
// j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native
|
||||
// ignoring the exception
|
||||
tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature);
|
||||
jthrowable throwable_obj = env->ExceptionOccurred();
|
||||
if (throwable_obj != NULL) {
|
||||
env->ExceptionClear();
|
||||
if (env->IsInstanceOf(throwable_obj, exceptionKlass)) {
|
||||
// j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native
|
||||
// ignoring the exception
|
||||
tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature);
|
||||
}
|
||||
} else {
|
||||
// register is failed w/o exception or w/ unexpected exception
|
||||
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);
|
||||
|
@ -36,6 +36,22 @@
|
||||
#define WB_END JNI_END
|
||||
#define WB_METHOD_DECLARE(result_type) extern "C" result_type JNICALL
|
||||
|
||||
#define CHECK_JNI_EXCEPTION_(env, value) \
|
||||
do { \
|
||||
if (env->ExceptionCheck()) { \
|
||||
env->ExceptionClear(); \
|
||||
return(value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_JNI_EXCEPTION(env) \
|
||||
do { \
|
||||
if (env->ExceptionCheck()) { \
|
||||
env->ExceptionClear(); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
class WhiteBox : public AllStatic {
|
||||
private:
|
||||
static bool _used;
|
||||
|
Loading…
Reference in New Issue
Block a user