RFR: 8358452: JNI exception pending in Java_sun_awt_screencast_ScreencastHelper_remoteDesktopKeyImpl of screencast_pipewire.c:1214 (ID: 51119) [v2]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Wed Jun 4 05:49:16 UTC 2025
On Wed, 4 Jun 2025 05:34:21 GMT, Alexander Zvegintsev <azvegint at 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.
>> For example, here ExceptionCheck is called not after AWT_UNLOCK but after the next JNI call `(*env)->NewObject`
>> https://github.com/openjdk/jdk/blob/ebd85288ce309b7dc7ff8b36558dd9f2a2300209/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c#L1281-L1290
>>
>> Normally we do ExceptionCheck after GetStringUTFChars
>> https://github.com/openjdk/jdk/blob/ebd85288ce309b7dc7ff8b36558dd9f2a2300209/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp#L1192-L1193
>>
>> Did you verify the warning goes off only by this PR change? If not, I will also recommend doing CHECK_EXCEPTION after GetStringUTFChars too..
>
>> 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?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25605#discussion_r2125699271
More information about the client-libs-dev
mailing list