2011-02-03 124 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)指示,否则,在热点一些实现细节改变,使此标志将是不可能的动态设定,或者如此不现实,它被禁用。换句话说,这是不会得到修正了一个错误。