JDK-6432048 : -verbose:jni or -Xcheck:jni do not report exessive local reference usage.
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-05-31
  • Updated: 2011-02-16
  • Resolved: 2010-09-01
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
  From
http://java.sun.com/docs/books/jni/html/refs.html#27592

"Java 2 SDK release 1.2 supports a command-line option -verbose:jni. When this option is enabled, the virtual machine implementation reports excessive local reference creation beyond the reserved capacity."

This however doesn't hold true.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile a native class w/ code like:

jclass LocalRunnable;
for (int i = 0; i < 16; i++)
         jclass LocalRunnable = env->FindClass("java/lang/Runnable");

Run it.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Excessive local reference creation is reported.
ACTUAL -
Not reported.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
class LocalRefs {
public native byte run();
public static void main(String[] args) {
new LocalRefs().run();
}
}

JNIEXPORT jbyte JNICALL Java_LocalRefs_run
  (JNIEnv *env, jobject obj);

JNIEXPORT jbyte JNICALL Java_LocalRefs_run
  (JNIEnv *env, jobject obj)
{
jclass LocalRunnable;
for (int i = 0; i < 16; i++)
         jclass LocalRunnable = env->FindClass("java/lang/Runnable");
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Enforce strictly manually.