On Wed, 4 Jun 2025 05:45:43 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

>>> We call AWT_UNLOCK in awt_Robot.c, gtk3_interface.c, awt_GraphicsEnv.c 
>>> where there's no ExceptionCheck after the call.
>> 
>> Neither awt_Robot.c nor gtk3_interface.c calls any JNI functions afterwards.
>> the awt_GraphicsEnv.c case doesn't call JNI functions between `AWT_LOCK` / 
>> `AWT_UNLOCK` (see explanation below about false positive).
>> 
>>> Normally we do ExceptionCheck after GetStringUTFChars
>> 
>> I added it just in case, but the GetStringUTFChars 
>> [documentation](https://docs.oracle.com/en/java/javase/21/docs/specs/jni/functions.html#getstringutfchars)
>>  doesn't mention any exceptions being thrown.
>> 
>>> Did you verify the warning goes off only by this PR change? 
>> 
>> it is the only reported line by the tool:
>> 
>> `JNI exception pending in 
>> Java_sun_awt_screencast_ScreencastHelper_remoteDesktopKeyImpl of 
>> screencast_pipewire.c:1214`
>> 
>> so it should resolve the issue.
>> 
>> But now I think it might be a false positive:
>> 
>> 1. `AWT_LOCK()` clears all exceptions:
>> https://github.com/openjdk/jdk/blob/78a392aa3b0cda52cfacfa15250fa61010519424/src/java.desktop/unix/native/common/awt/awt.h#L86-L95
>> 2. `awt_getX11KeySym` doesn't call JNI at all
>> 3. `AWT_UNLOCK()`  also clears an exception,  and rethrows a previously 
>> pending exception, if any.
>> https://github.com/openjdk/jdk/blob/78a392aa3b0cda52cfacfa15250fa61010519424/src/java.desktop/unix/native/common/awt/awt.h#L97-L110
>> 
>> Since neither 1. nor 2. produces an exception, no exception will be thrown.
>
> 3 rethrows the exception, maybe tool is complaining about that..maybe we 
> should find out what that exception is and who is throwing?
> Should we call EXCEPTION_CHECK_DESCRIBE instead to find out what exception it 
> is complaining about by running the tool?
> 
> Also, dont we need to do ExceptionClear too in addition to ExcepionCheck to 
> clear out the exception else it will keep it pending?

I don't think so. Let Java catch it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25605#discussion_r2125723089

Reply via email to