Running Java 6 on Snow Leopard.
It is assumed that you enable ExtendedDTraceProbes in a running Java process using the jinfo utility . Even the jinfo command line says to enable common flags:
Usage: jinfo [option] <pid> (to connect to running process) ... where <option> is one of: -flag [+|-]<name> to enable or disable the named VM flag
And as far as I know, DTrace flags do not really matter, it only matters their presence or absence.
But when I try to do this, I get one of two errors, depending on whether I predict it with sudo or not.
Assuming:
Jps
1234 StayRunning ...
The same user as the StayRunning process:
jinfo -flag + ExtendedDTraceProbes 1234
Exception in thread "main" java.io.IOException: Command failed in target VM at sun.tools.attach.MacosxVirtualMachine.execute(MacosxVirtualMachine.java:200) at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:195) at sun.tools.attach.HotSpotVirtualMachine.setFlag(HotSpotVirtualMachine.java:172) at sun.tools.jinfo.JInfo.flag(JInfo.java:111) at sun.tools.jinfo.JInfo.main(JInfo.java:58)
Trying as root:
sudo jinfo -flag + ExtendedDTraceProbes 1234
Password: (which I enter) 1234: Unable to open socket file: target process not responding or HotSpot VM not loaded
the error is on the second line, and, of course, the process is still running.
Oddly enough, this page does not show the "+" option for OS X , but my own computer prints a usage message.
Here is my simple code. It does not work like Eclipse.
StayRunning.java
class StayRunning { public static void main( String [] args ) throws Exception { long counter = 0L; while( true ) { Thread.sleep( 1000 ); counter++; System.out.println( "tick "+counter ); } } }