RFR: 8310628: GcInfoBuilder.c missing JNI Exception checks

Kevin Walls kevinw at openjdk.org
Thu Jun 22 11:11:06 UTC 2023


JNI calls were identified, where we do not check for a pending Exception afterwards.

(JDK-8162530 cleaned up up some of these kind of issues some years back, but more were found.)

I tested a code change to manually create an Exception before some of the new ExceptionCheck calls, and this is correctly recognised, we see an Exception thrown by the native getLastGcInfo0, e.g. 

java.lang.NullPointerException: XXX Test Exception
        at jdk.management/com.sun.management.internal.GcInfoBuilder.getLastGcInfo0(Native Method)
        at jdk.management/com.sun.management.internal.GcInfoBuilder.getLastGcInfo(GcInfoBuilder.java:77)
        at jdk.management/com.sun.management.internal.GarbageCollectorExtImpl.getLastGcInfo(GarbageCollectorExtImpl.java:69)
        at LastGCInfo.main(LastGCInfo.java:53)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
        at java.base/java.lang.Thread.run(Thread.java:1570)

Tested with all of test/jdk/com/sun/management including test/jdk/com/sun/management/GarbageCollectorMXBean/LastGCInfo.java

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

Commit messages:
 - 8310628: GcInfoBuilder.c missing JNI Exception checks

Changes: https://git.openjdk.org/jdk/pull/14613/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14613&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8310628
  Stats: 29 lines in 1 file changed: 20 ins; 0 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/14613.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14613/head:pull/14613

PR: https://git.openjdk.org/jdk/pull/14613


More information about the serviceability-dev mailing list