RFR[10] 8190984 : tools/launcher/TestXcheckJNIWarnings.java WARNING was found in the output

Brent Christian brent.christian at oracle.com
Tue Dec 12 23:38:57 UTC 2017


Please review this small change to the System.initProperties() native 

The tools/launcher/TestXcheckJNIWarnings.java has begun to fail due to 
this warning being issued:

WARNING: JNI local refs: 41, exceeds capacity: 40
         at java.lang.System.initProperties(java.base/Native Method)
         at java.lang.System.initPhase1(java.base/System.java:1943)

This has only been seen on solaris-sparc with LANG=C.  In fact, the 
warning can also be seen with a simple HelloWorld program, run with 
-Xcheck:jni.  This started happening as of JDK-8043224 ("-Xcheck:jni 
improvements to exception checking and excessive local refs").

The following change should be made to prevent the warning:

diff -r ed1bb7743b3e src/java.base/share/native/libjava/System.c
--- a/src/java.base/share/native/libjava/System.c	Tue Dec 12 19:05:02 
2017 +0100
+++ b/src/java.base/share/native/libjava/System.c	Tue Dec 12 15:21:03 
2017 -0800
@@ -186,6 +186,9 @@
      jobject ret = NULL;
      jstring jVMVal = NULL;

+    if ((*env)->EnsureLocalCapacity(env, 50) < 0) {
+        return NULL;
+    }
      sprops = GetJavaProperties(env);
      CHECK_NULL_RETURN(sprops, NULL);

Of note: an additional change is needed, to EnsureLocalCapacity itself:

8193222 : EnsureLocalCapacity() should maintain capacity requests 
through multiple calls

That fix has already been proposed and reviewed.
These two fixes should be pushed together via hs, which David has kindly 
offered to do, pending code review approval of my change here.


More information about the core-libs-dev mailing list