RFR: 8358452: JNI exception pending in Java_sun_awt_screencast_ScreencastHelper_remoteDesktopKeyImpl of screencast_pipewire.c:1214 (ID: 51119) [v2]
Alexander Zvegintsev
azvegint at openjdk.org
Wed Jun 4 05:39:36 UTC 2025
On Wed, 4 Jun 2025 03:49:05 GMT, Prasanta Sadhukhan <psadhukhan 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.
Neither awt_Robot.c nor gtk3_interface.c calls any JNI functions afterwards.
I'm not sure why the tool didn't trigger regarding the awt_GraphicsEnv.c case.
> 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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25605#discussion_r2125687104
More information about the client-libs-dev
mailing list