JDK-8296709 : WARNING: JNI call made without checking exceptions
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 11,17,20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2022-11-09
  • Updated: 2024-10-25
  • Resolved: 2022-11-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 20
17.0.14-oracleFixed 20 b24Fixed
Related Reports
Relates :  
Description
After a JNI call returned, it should be checked whether there is a pending exception. Otherwise, at the moment of the next JNI call, you will receive a warning message. 

This rule is obviously not adhered to in src/jdk.jdwp.agent/share/native/libjdwp/util.c. To reproduce, simply issue the command 
  bin/java -Xcheck:jni -agentlib:jdwp=transport=dt_socket,server=y,suspend=n -version
and you will see the warning.

The rule violation was found with the help of the test
  test/jdk/tools/launcher/TestXcheckJNIWarnings.java 
using SAP's commercial VM offering. For the OpenJDK variant to show the warning, you will need to specify the above -agentlib parameter. 

Comments
Fix request [17u] I backport this for parity with 17.0.14-oracle. Low risk, obvious and well hung fix. Clean backport. Test reproduces JDK-8296936 as expected. SAP nightly testing passed.
23-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk17u-dev/pull/2983 Date: 2024-10-22 10:05:44 +0000
22-10-2024

Hi [~lucy] , there seem to be few more places in the openJDK codebase , where the JNI exception check is missing after the CallStaticObjectMethod . For example : https://github.com/openjdk/jdk/blob/7452d50be58cfa8e97c57ca145a809409945f883/src/jdk.crypto.mscapi/windows/native/libsunmscapi/security.cpp#L2719 What do you think about this, do we need adjustment at such places ?
31-10-2023

Changeset: eac26f4e Author: Lutz Schmidt <lucy@openjdk.org> Date: 2022-11-16 15:00:20 +0000 URL: https://git.openjdk.org/jdk/commit/eac26f4eb2b717676267c75e65e76fc3b958c9a7
16-11-2022

Moving to core-svc/debugger since that's who owns libjdwp.
10-11-2022

No problem - neither of the warnings are new, but getting rid of any of them is good!
10-11-2022

Forget the below comment. For some reason, I did not see the first WARNING message. Basically, you confirmed my observation. I should have copied the original output into the description. -------------- Thank you, this is interesting! My last sync was Nov 09, around 16:00 UTC. I did not test on linux-x64, though. My local machine is darwinintel64. I will resync now and test on various platforms.
10-11-2022

For the record, here's my output from a latest JDK today: $ ../build/linux-x64/images/jdk/bin/java -Xcheck:jni -agentlib:jdwp=transport=dt_socket,server=y,suspend=n -version WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethod WARNING: JNI local refs: 467, exceeds capacity: 32 Listening for transport dt_socket at address: 40889 java version "20-internal" 2023-03-21 Java(TM) SE Runtime Environment (build 20-internal-2022-11-09-1314123.kwalls...) Java HotSpot(TM) 64-Bit Server VM (build 20-internal-2022-11-09-1314123.kwalls..., mixed mode, sharing) bash-4.2$
10-11-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11083 Date: 2022-11-10 09:02:02 +0000
10-11-2022