2011-02-03 126 views
4

在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); 
     } 
    } 
} 
+0

這個問題得到了風滾草。:-(許多開發者使用Mac,所以我很驚訝的是他人看到這個?或者你們都有同樣的問題,還在等待答案?嗯......好吧,如果你有這個問題,至少要評論!痛苦愛公司你知道。 – 2011-02-27 00:05:08

回答

3

你是正確的,這種探針是一種既可以「設置」或「未設置」(即沒有特別的「價值」與之相關聯)。

這幾乎肯定是Hotspot JVM中的一個(長期)錯誤,並不是OSX所特有的。這是從別人無法通過金佛山上的Windows設置VM標誌報告:

http://www.herongyang.com/Java-Tools/jstack-jinfo-Change-HotSpot-VM-Option.html

我可以提供第一手的經驗是無法設置ExtendedDTraceProbes和(科學!)等幾個標誌通過在Linux上金佛山動態。事實上,經過幾次嘗試之後,我無法找到一個標誌,我可以動態設置

http://bugs.sun.com/view_bug.do;jsessionid=24c1d7e1b0cda2ffffffff97aef6bbd818cf2?bug_id=6445836

最有趣的是,在評估部分: 「金佛山-flag是一個臨時的解決方案,以動態地啓用DTrace探測器作爲小敏說。

我碰到在Sun /甲骨文相關的錯誤來了,這是假設消失。「

部分基於此,以及我自己過去在熱點文檔嚴重過時和/或不準確的經驗,我懷疑,儘管有jinfo的文檔/聯機幫助頁,以及探針本身(http://download.oracle.com/javase/6/docs/technotes/guides/vm/dtrace.html)指示,否則,在熱點一些實現細節改變,使此標誌將是不可能的動態設定,或者如此不現實,它被禁用。換句話說,這是不會得到修正了一個錯誤。