This discussion is archived
1 Reply Latest reply: Sep 9, 2011 7:26 PM by EJP RSS

JRockit reuses local references when calling JVMTI event callbacks

887326 Newbie
Currently Being Moderated
[At least] During VM startup, multiple calls to the ClassPrepare event handler are made using the same local reference for the thread parameter. If DeleteLocalReference is called before returning from the ClassPrepare event, working with the thread parameter passed to subsequent calls to ClassPrepare will crash the VM.

While the JVMTI documentation is unclear about whether or not the user is allowed to delete local references sent as parameters to the event callbacks, this behavior does differ from the Sun Hotspot implementation and seems to violate the fundamental reason why local references are used for all values sent from the VM to native methods. The relevant line in the JVMTI specification is:
Some JVM TI events identify objects with JNI references. All references in JVM TI events are JNI local references and will become invalid after the event callback returns.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points