Running Java 6 on Snow Leopard.
You're supposed to be able to turn on ExtendedDTraceProbes on a running Java process with the jinfo utility. Even at my command prompt jinfo talks about about enabling general 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 the DTrace flags do not have any special value, it's just their presence or absence that matters.
But when I try to do it I get one of two errors, depending on whether I preface it with sudo or not.
Assuming:
jps
1234 StayRunning
...
Same user as 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, this page doesn't show the "+" option for OS X, but my own machine prints out the usage message.
Here's my simple code. It fails similarly with 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 );
}
}
}