RFR: 8345422: Fix JNI Checker "in native method" warnings in the debug agent and debugger tests

Chris Plummer cjplummer at openjdk.org
Wed Dec 4 23:05:39 UTC 2024


On Wed, 4 Dec 2024 22:56:50 GMT, Alex Menkov <amenkov at openjdk.org> wrote:

>> I think there are two types of checks for exceptions; implicit and explicit.
>> 
>> For the implicit check, the "call" functions all set a flag saying an exception check is needed. So this will trigger the "in native method" warning on the next call regardless of whether or not an exception is actually thrown. What I'm not so sure of is which JNI functions check this flag (I know only the "call" functions set it). Since we don't see a warning for this saveGlobalRef() case, I'm inclined to think that NewGlobalRef does not check the flag.
>> 
>> I believe (but I'm not sure) there is also a second type of check that is explicit and only made to see if there is actually a pending exception when the JNI API is called. Possibly this check is done on all calls, but this saveGlobalRef() case never triggers it because there can't be a pending exception if an object was returned.
>
>> What I'm not so sure of is which JNI functions check this flag (I know only the "call" functions set it)
> 
> In `invokeNonVirtual` we calls `CallNonvirtualObjectMethodA` JNI function and then call `saveGlobalRef`, it looks strange if the case don't cause the warning.

I've not sure if NewGlobalRef checks the flag or only checks if there is actually a pending exception. I'm trying to find that out.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22528#discussion_r1870393773


More information about the serviceability-dev mailing list