2

我正在使用 JDI,并发现调用 com.sun.jdi.VirtualMachine#dispose 会在某些情况下挂起。

线程堆栈是:

 "qtp1764345202-39" prio=5 tid=0x00007f830a14f000 nid=0x10d03 in Object.wait() [0x0000000128ea6000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00000007039b1f40> (a com.sun.tools.jdi.Packet)
        at java.lang.Object.wait(Object.java:503)
        at com.sun.tools.jdi.TargetVM.waitForReply(TargetVM.java:300)
        - locked <0x00000007039b1f40> (a com.sun.tools.jdi.Packet)
        at com.sun.tools.jdi.VirtualMachineImpl.waitForTargetReply(VirtualMachineImpl.java:1036)
        at com.sun.tools.jdi.PacketStream.waitForReply(PacketStream.java:69)
        at com.sun.tools.jdi.JDWP$VirtualMachine$Dispose.waitForReply(JDWP.java:445)
        at com.sun.tools.jdi.JDWP$VirtualMachine$Dispose.process(JDWP.java:431)
        at com.sun.tools.jdi.VirtualMachineImpl.dispose(VirtualMachineImpl.java:555)

从反编译的代码中,我看到了这个:

void waitForReply(Packet var1) {
    synchronized(var1) {
        while(!var1.replied && this.shouldListen) {
            try {
                var1.wait();
            } catch (InterruptedException var5) {
                ;
            }
        }

        if(!var1.replied) {
            throw new VMDisconnectedException();
        }
    }
}

这里好像有死锁,这是JDK的错误吗?我正在使用热点 JDK 7。

java 版本 "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, 混合模式)

4

0 回答 0