JBR-3542 Fix -Xcheck:jni warnings

Fixes warnings coming from JBR-specific code in addition to those fixed
by 8269223.
This commit is contained in:
Maxim Kartashev
2021-08-31 13:38:26 +03:00
committed by jbrbot
parent a9ffdb7f32
commit d575ccd377
4 changed files with 14 additions and 5 deletions

View File

@@ -592,6 +592,7 @@ AWT_ASSERT_APPKIT_THREAD;
DECLARE_CLASS(jc_CCursorManager, "sun/lwawt/macosx/CCursorManager");
DECLARE_STATIC_METHOD(sjm_resetCurrentCursor, jc_CCursorManager, "resetCurrentCursor", "()V");
(*env)->CallStaticVoidMethod(env, jc_CCursorManager, sjm_resetCurrentCursor);
CHECK_EXCEPTION();
}
- (BOOL) canBecomeMainWindow {

View File

@@ -129,6 +129,7 @@ JNI_COCOA_ENTER(env);
JNI_COCOA_ENTER(blockEnv);
// call the user's runnable
(*blockEnv)->CallVoidMethod(blockEnv, runnableRef, jm_run);
CHECK_EXCEPTION_IN_ENV(blockEnv);
(*blockEnv)->DeleteGlobalRef(blockEnv, runnableRef);
JNI_COCOA_EXIT(blockEnv);
});

View File

@@ -183,23 +183,25 @@
* or maybe a way for the app to continue running depending on the exact
* nature of the problem that has been detected and how survivable it is.
*/
#define CHECK_EXCEPTION() \
if ((*env)->ExceptionOccurred(env) != NULL) { \
#define CHECK_EXCEPTION_IN_ENV(env) \
if ((*(env))->ExceptionOccurred(env) != NULL) { \
if ([NSThread isMainThread] == YES) { \
if (getenv("JNU_APPKIT_TRACE")) { \
(*env)->ExceptionDescribe(env); \
(*(env))->ExceptionDescribe(env); \
NSLog(@"%@",[NSThread callStackSymbols]); \
} else { \
(*env)->ExceptionClear(env); \
(*(env))->ExceptionClear(env); \
} \
} \
if (getenv("JNU_NO_COCOA_EXCEPTION") == NULL) { \
[NSException raise:NSGenericException format:@"Java Exception"]; \
} else { \
(*env)->ExceptionClear(env); \
(*(env))->ExceptionClear(env); \
} \
};
#define CHECK_EXCEPTION() CHECK_EXCEPTION_IN_ENV(env)
#define CHECK_EXCEPTION_NULL_RETURN(x, y) \
CHECK_EXCEPTION(); \
if ((x) == NULL) { \

View File

@@ -349,6 +349,11 @@ static int getScreenResolution(JNIEnv *env) {
jthrowable exc;
jclass tk = (*env)->CallStaticObjectMethod(
env, tkClass, getDefaultToolkitMID);
exc = (*env)->ExceptionOccurred(env);
if (exc) {
(*env)->ExceptionClear(env);
return DEFAULT_DPI;
}
int dpi = (*env)->CallIntMethod(env, tk, getScreenResolutionMID);
/* Test if there is no exception here (can get java.awt.HeadlessException)