Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6434824
Votes 0
Synopsis JVMTI Spec: Agent_OnLoad and Agent_OnAttach need clarifications
Category hotspot:jvmti
Reported Against
Release Fixed mustang(b92)
State 10-Fix Delivered, Verified, bug
Priority: 3-Medium
Related Bugs 6434825
Submit Date 06-JUN-2006
Description
The JVM TI specification (1.1.95) at:
 http://download.java.net/jdk6/doc/platform/jvmti/jvmti.html
states as follows about native agent's loading in OnLoad and Live Phase:
  --- Excerpt-from-spec --- 
  ...
  Agent Start-Up (OnLoad phase)
  If an agent is started during the OnLoad phase then it must export a start-up
  function with the following prototype:

  JNIEXPORT jint JNICALL
  Agent_OnLoad(JavaVM *vm, char *options, void *reserved)

  This function will be called by the VM when the library is loaded.
  ...
  As the agent is started in the OnLoad phase, the Agent_OnAttach is not invoked.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  --- End-of-excerpt-from-spec --- 
and
  --- Excerpt-from-spec --- 
  ...
  Agent Start-Up (Live phase)
  If an agent is started during the live phase then it must export a start-up
  function with the following prototype:

  JNIEXPORT jint JNICALL
  Agent_OnAttach(JavaVM* vm, char *options, void *reserved)

  As the agent is started in the live phase the Agent_OnLoad function is not invoked.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  Note that some capabilities may not be available in the live phase.
  ...
  --- End-of-excerpt-from-spec --- 

It's not fully clear from the spec that if an agent library is specified 
with -agentlib/-agentpath then only Agent_OnLoad is called, and, similarly, 
if an agent library is loaded into a running system then only Agent_OnAttach 
is called.

There is another aspect of this that is unclear, or worse, it says 
"when the library is loaded". What if one "foo" agent is launched on 
the command line, and later another "foo" agent is launched via attach.  
It looks like Agent_OnLoad should be called for the first and 
Agent_OnAttach for the second even though the library is already loaded. 
Similarly for two agents loaded from the command line.

The JVM TI specification should be more descriptive here.
Posted Date : 2006-06-06 20:39:35.0
Work Around
N/A
Evaluation
This is confusing and must be corrected.
This is a spec clarification only, marking as mustang-doc
Posted Date : 2006-06-06 23:06:30.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang