RFR: 8259343: [macOS] Update JNI error handling in Cocoa code.

Sergey Bylokhov serb at openjdk.java.net
Mon Jan 11 06:07:59 UTC 2021


On Fri, 8 Jan 2021 19:05:09 GMT, Phil Race <prr at openjdk.org> wrote:

>> Proposed updates to JNI error handling.
>
> src/java.desktop/macosx/native/libosxapp/JNIUtilities.h line 46:
> 
>> 44:               if ((*env)->ExceptionOccurred(env) != NULL) { \
>> 45:                   (*env)->ExceptionDescribe(env); \
>> 46:               } \
> 
> So the update here is that if we are not on the appkit thread, make sure a java exception is thrown.
> If we are on the appkit thread, clear any java exception since it isn't going anywhere but do it using
> describe which prints it.

I read the logic of the method differently, probably the wrong indents?
  - If we are not on the toolkit thread then
    - Check ExceptionOccurred -> throw JNU_ThrowInternalError if needed or check exception again ->call ExceptionDescribe
  - NSException raise at the end.

-------------

PR: https://git.openjdk.java.net/jdk/pull/1967



More information about the build-dev mailing list