144 Java Stand-alone Applications on z/OS Volume II
export PATH=/usr/lpp/java/J5.0/bin:$PATH
export LIBPATH=./:$LIBPATH
b. Generate the object file:
cc -c -o JVMTIAgent.o -W c,exportall
-I/usr/lpp/java/J5.0/include JVMTIAgent.c
c. Build the shared library:
cc -o libTIAgent.so -W l,dll JVMTIAgent.o
d. Compile the Java simple test case:
javac JVMTITest.java
e. When users execute the agent, they will receive the following output:
$ java -agentlib:TIAgent JVMTITest
For more information about writing agents using JVMTI, refer to the following
sites:
http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html
http://java.sun.com/developer/technicalArticles/Programming/jvmti
9.3 Transition from JVMPI to JVMTI
The Java Virtual Machine Profiler Interface (JVMPI) is available in the SDK 5.0,
but the JVMPI has been deprecated. Users are encouraged to move to JVMTI.
Because the complexity to move from JVMPI to JVMTI depends on how JVMPI
has been used, this section provides tips to help you make the transition
successfully:
򐂰 The JVMTI offers more functionality and improves performance, as compared
to JVMPI. Table 9-1 on page 145 is a simple list of JVMPI-to-JVMTI mapping.
Agent loaded
Got VM init event
Creating and running 2 threads...
Got VM Death event
Agent Unloaded
Chapter 9. Java Virtual Machine Tool Interface 145
Table 9-1 Mapping between JVMPI and JVMTI functions
򐂰 In the JVMTI, each event has its own callback routine. Table 9-2 shows the
mapping between some of the events.
Table 9-2 Mapping between JVMPI and JVMTI events
򐂰 The most important difference between JVMPI and JVMTI is the way Java
heap is handled, as described here:
When you request heap dump using JVMPI, a single chunk of data is
returned, which needs to be parsed by the agent.
In JVMTI, there are various functions available to the user to traverse the
heap.
For more detailed information about the transition from JVMPI to JVMTI, refer to
the following site:
http://java.sun.com/developer/technicalArticles/Programming/jvmpitransition/
JVMPI JVMTI
GetCallTrace GetStackTrace
EnableEvent SetEventNotificationMode
Use jvmtiEventMode == JVMTI_ENABLE
DisableEvent SetEventNotificationMode
Use jvmtiEventMode ==
JVMTI_DISABLE
DisableGC & EnableGC There is no JVMTI equivalent because
JVMTI does not require GC to be
disabled for any events.
GetThreadStatus GetThreadState
JVMPI JVMTI
JVMPI_EVENT_METHOD_ENTRY JVMTI_EVENT_METHOD_ENTRY
JVMPI_EVENT_METHOD_EXIT JVMTI_EVENT_METHOD_EXIT
JVMPI_EVENT_JVM_INIT_DONE JVMTI_EVENT_VM_INIT
JVMPI_EVENT_THREAD_START JVMTI_EVENT_THREAD_START
JVMPI_EVENT_JVM_SHUT_DOWN JVMTI_EVENT_VM_DEATH
146 Java Stand-alone Applications on z/OS Volume II

Get Java Stand-alone Applications on z/OS Volume II now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.