RFR: 8366149: JNI exception pending in Java_sun_awt_X11GraphicsDevice_pGetBounds of awt_GraphicsEnv.c:1484

Phil Race prr at openjdk.org
Fri Sep 5 04:38:23 UTC 2025


On Fri, 5 Sep 2025 01:43:30 GMT, Damon Nguyen <dnguyen at openjdk.org> wrote:

> In the scenario where AWT's UNLOCK API encounters a pendingException, the env pointer throws the pendingException (as seen in `awt.h`). However, in `Java_sun_awt_X11GraphicsDevice_pGetBounds`, after `AWT_UNLOCK`, the bounds var is set. The exception check does not occur until after the bounds is set, so the bounds may be set to an undesired value. This fix adds another exception check to look for this pendingException after `AWT_UNLOCK`.

src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c line 1289:

> 1287:             AWT_UNLOCK ();
> 1288: 
> 1289:             if ((*env)->ExceptionCheck(env)) {

Is the problem that we are here because bounds == null and one way this is possible is that the call at line 1265 failed? Meaning threw an unlikely exception.
If so, maybe that is where we should just "return NULL".

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27110#discussion_r2324068770


More information about the client-libs-dev mailing list