On Wed, 4 Dec 2024 21:49:05 GMT, Alex Menkov <amen...@openjdk.org> wrote:

>> I don't believe so because if an object is returned then that implies that 
>> there was no exception thrown.
>
> It's the same like other calls here (invokeVirtual, etc), so I'd expect it 
> produces "in native method" warning.
> Maybe we don't have a test for this so this case is not detected?

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.

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

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

Reply via email to