Snow Leopard で Java 6 を実行しています。
jinfo ユーティリティを使用して、実行中の Java プロセスで ExtendedDTraceProbes をオンにできるはずです。私のコマンド プロンプトでも、jinfoは一般的なフラグを有効にすることについて話しています。
Usage:
jinfo [option] <pid>
(to connect to running process)
...
where <option> is one of:
-flag [+|-]<name> to enable or disable the named VM flag
私が知る限り、DTrace フラグに特別な価値はありません。重要なのは、その有無だけです。
しかし、それを実行しようとすると、sudo で始まるかどうかに応じて、2 つのエラーのいずれかが発生します。
想定:
jps
1234 StayRunning
...
StayRunning プロセスと同じユーザー:
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)
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
エラーは2 行目にあり、もちろんプロセスはまだ実行中です。
奇妙なことに、このページには OS X の「+」オプションは表示されませんが、私のマシンでは使用方法のメッセージが出力されます。
これが私の簡単なコードです。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 );
}
}
}