Using the Java API

You can dynamically control trace in a number of ways from a Java™ application by using the com.ibm.jvm.Trace class.

Activating and deactivating tracepoints

int set(String cmd);

The Trace.set() method allows a Java application to select tracepoints dynamically. For example:
Trace.set(“iprint=all”); 
The syntax is the same as that used in a trace properties file for the print, iprint, count, maximal, minimal and external trace options.

A single trace command is parsed per invocation of Trace.set, so to achieve the equivalent of -Xtrace:maximal=j9mm,iprint=j9shr two calls to Trace.set are needed with the parameters maximal=j9mm and iprint=j9shr

Obtaining snapshots of trace buffers

void snap();

You must have activated trace previously with the maximal or minimal options and without the out option.

Suspending or resuming trace

void suspend();

The Trace.suspend() method suspends tracing for all the threads in the JVM.

void resume();

The Trace.resume() method resumes tracing for all threads in the JVM. It is not recursive.

void suspendThis();

The Trace.suspendThis() method decrements the suspend and resume count for the current thread and suspends tracing the thread if the result is negative.

void resumeThis();

The Trace.resumeThis() method increments the suspend and resume count for the current thread and resumes tracing the thread if the result is not negative.