在Snow Leopard上運行Java 6。無法在Mac OS X上通過jinfo啓用DTrace探針
你應該能夠turn on ExtendedDTraceProbes on a running Java process with the jinfo utility。即使在我的命令提示符下金佛山約會談有關啓用通用標誌:
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作爲前言。
假設:
JPS
1234 StayRunning
...
相同的用戶StayRunning過程:
金佛山-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,作爲根:
須藤金佛山標誌+擴展dedDTraceProbes 1234
Password: (which I enter)
1234: Unable to open socket file: target process not responding or HotSpot VM not loaded
的錯誤是在第二行上,當然該過程仍在運行。
奇怪的是,this page doesn't show the "+" option for 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);
}
}
}
這個問題得到了風滾草。:-(許多開發者使用Mac,所以我很驚訝的是他人看到這個?或者你們都有同樣的問題,還在等待答案?嗯......好吧,如果你有這個問題,至少要評論!痛苦愛公司你知道。 – 2011-02-27 00:05:08