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 );
}
}
}
You are correct that this probe is one that can either be 'set' or 'unset' (ie no particular 'value' is associated with it).
This is almost definitely a (longstanding) bug in the Hotspot JVM, and not unique to OSX. Here is a report from someone unable to set VM flags via jinfo on Windows:
http://www.herongyang.com/Java-Tools/jstack-jinfo-Change-HotSpot-VM-Option.html
I can provide firsthand experience of being unable to set ExtendedDTraceProbes and (for science!) several other flags dynamically via jinfo on Linux. In fact, after a handful of tries I was not able to find a flag that I could set dynamically.
I came across a relevant bug on Sun/Oracle:
https://bugs.java.com/bugdatabase/view_bug;jsessionid=24c1d7e1b0cda2ffffffff97aef6bbd818cf2?bug_id=6445836
Most interestingly, in the Evaluation section: "jinfo -flag is an interim solution to enable DTrace probes dynamically. As Mandy said, this is suppose to go away."
Based in part on this, as well as my own past experiences with Hotspot documentation being grossly out of date and/or inaccurate, I suspect that, despite the documentation/manpage for jinfo, as well as the documentation for the probes themselves (http://download.oracle.com/javase/6/docs/technotes/guides/vm/dtrace.html) indicating otherwise, that some implementation detail in Hotspot changed to make the dynamic setting of this flag either impossible, or so impractical that it was disabled. In other words, this is a bug that will not get fixed.