Java 类com.sun.jdi.VMDisconnectedException 实例源码

项目:incubator-netbeans    文件:VisualDebuggerListener.java   
private void stopDebuggerRemoteService(JPDADebugger d) {
    ClassObjectReference serviceClass = RemoteServices.getServiceClass(d, RemoteServices.ServiceType.AWT);
    if (serviceClass == null) {
        return ;
    }
    try {
        ReferenceType serviceType = serviceClass.reflectedType();
        Field awtAccessLoop = serviceType.fieldByName("awtAccessLoop"); // NOI18N
        if (awtAccessLoop != null) {
            ((ClassType) serviceType).setValue(awtAccessLoop, serviceClass.virtualMachine().mirrorOf(false));
        }
        serviceClass.enableCollection();
    } catch (VMDisconnectedException vdex) {
        // Ignore
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
}
项目:incubator-netbeans    文件:CallStackFrameImpl.java   
public List<MonitorInfo> getOwnedMonitors() {
    List<MonitorInfo> threadMonitors;
    try {
        threadMonitors = getThread().getOwnedMonitorsAndFrames();
    } catch (InvalidStackFrameException itsex) {
        threadMonitors = Collections.emptyList();
    } catch (VMDisconnectedException e) {
        threadMonitors = Collections.emptyList();
    }
    if (threadMonitors.size() == 0) {
        return threadMonitors;
    }
    List<MonitorInfo> frameMonitors = new ArrayList<MonitorInfo>();
    for (MonitorInfo mi : threadMonitors) {
        if (this.equals(mi.getFrame())) {
            frameMonitors.add(mi);
        }
    }
    return Collections.unmodifiableList(frameMonitors);
}
项目:incubator-netbeans    文件:JPDAClassTypeImpl.java   
@Override
public boolean isInstanceOf(String className) {
    List<ReferenceType> classTypes;
    try {
        classTypes = VirtualMachineWrapper.classesByName(MirrorWrapper.virtualMachine(classType), className);
    } catch (InternalExceptionWrapper | VMDisconnectedExceptionWrapper ex) {
        return false;
    }
    for (ReferenceType rt : classTypes) {
        try {
            if (EvaluatorVisitor.instanceOf(classType, rt)) {
                return true;
            }
        } catch (VMDisconnectedException vmdex) {
            return false;
        } catch (InternalException iex) {
            // procceed
        }
    }
    return false;
}
项目:OpenJSharp    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:jdk8u-jdk    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:openjdk-jdk10    文件:MyExecutionControl.java   
private synchronized void disposeVM() {
    try {
        if (vm != null) {
            vm.dispose(); // This could NPE, so it is caught below
            vm = null;
        }
    } catch (VMDisconnectedException ex) {
        // Ignore if already closed
    } catch (Throwable e) {
        fail("disposeVM threw: " + e);
    } finally {
        if (process != null) {
            process.destroy();
            process = null;
        }
    }
}
项目:openjdk-jdk10    文件:TargetVM.java   
void send(Packet packet) {
    String id = String.valueOf(packet.id);

    synchronized(waitingQueue) {
        waitingQueue.put(id, packet);
    }

    if ((vm.traceFlags & VirtualMachineImpl.TRACE_RAW_SENDS) != 0) {
        dumpPacket(packet, true);
    }

    try {
        connection.writePacket(packet.toByteArray());
    } catch (IOException e) {
        throw new VMDisconnectedException(e.getMessage());
    }
}
项目:openjdk-jdk10    文件:VirtualMachineManagerImpl.java   
public synchronized VirtualMachine createVirtualMachine(
                                    Connection connection,
                                    Process process) throws IOException {

    if (!connection.isOpen()) {
        throw new IllegalStateException("connection is not open");
    }

    VirtualMachine vm;
    try {
        vm = new VirtualMachineImpl(this, connection, process,
                                               ++vmSequenceNumber);
    } catch (VMDisconnectedException e) {
        throw new IOException(e.getMessage());
    }
    targets.add(vm);
    return vm;
}
项目:java-debug    文件:ThreadsRequestHandler.java   
/**
 * Recycle the related ids owned by the specified thread.
 */
public static void checkThreadRunningAndRecycleIds(ThreadReference thread, IDebugAdapterContext context) {
    try {
        IEvaluationProvider engine = context.getProvider(IEvaluationProvider.class);
        engine.clearState(thread);
        boolean allThreadsRunning = !DebugUtility.getAllThreadsSafely(context.getDebugSession()).stream()
                .anyMatch(ThreadReference::isSuspended);
        if (allThreadsRunning) {
            context.getRecyclableIdPool().removeAllObjects();
        } else {
            context.getRecyclableIdPool().removeObjectsByOwner(thread.uniqueID());
        }
    } catch (VMDisconnectedException ex) {
        // isSuspended may throw VMDisconnectedException when the VM terminates
        context.getRecyclableIdPool().removeAllObjects();
    } catch (ObjectCollectedException collectedEx) {
        // isSuspended may throw ObjectCollectedException when the thread terminates
        context.getRecyclableIdPool().removeObjectsByOwner(thread.uniqueID());
    }
}
项目:andbg    文件:EventThread.java   
@Override
    public void run() {
        EventQueue queue = ctx.getVm().eventQueue();
        while (connected) {
            try {
                eventSet = queue.remove();
                EventIterator it = eventSet.eventIterator();
                while (it.hasNext()) {
                    handleEvent(it.nextEvent());
                }
//                eventSet.resume();
            } catch (InterruptedException exc) {
                // Ignore
            } catch (VMDisconnectedException discExc) {
                handleDisconnectedException();
                break;
            }
        }
    }
项目:jdk8u_jdk    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:infobip-open-jdk-8    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:jdk8u-dev-jdk    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:jdk7-jdk    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:openjdk-source-code-learn    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:jdivisitor    文件:EventThread.java   
/**
 * Run the event handling thread.
 * 
 * As long as the thread remains connected to the VM, events are removed
 * from the queue and dispatched.
 */
@Override
public void run() {
    EventQueue queue = vm.eventQueue();

    while (connected) {
        try {
            EventSet eventSet = queue.remove();

            EventIterator eventIterator = eventSet.eventIterator();
            while (eventIterator.hasNext()) {
                handleEvent(eventIterator.nextEvent());
            }
            eventSet.resume();
        } catch (InterruptedException ie) {
            vm.dispose();
            break;
        } catch (VMDisconnectedException vmde) {
            handleDisconnectedException();
            break;
        }
    }
}
项目:OLD-OpenJDK8    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:tools-idea    文件:PopFrameAction.java   
public void actionPerformed(AnActionEvent e) {
  Project project = e.getData(PlatformDataKeys.PROJECT);
  StackFrameProxyImpl stackFrame = getStackFrameProxy(e);
  if(stackFrame == null) {
    return;
  }
  try {
    DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
    DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if(debugProcess == null) {
      return;
    }
    debugProcess.getManagerThread().schedule(debugProcess.createPopFrameCommand(debuggerContext, stackFrame));
  }
  catch (NativeMethodException e2){
    Messages.showMessageDialog(project, DebuggerBundle.message("error.native.method.exception"), ActionsBundle.actionText(DebuggerActions.POP_FRAME), Messages.getErrorIcon());
  }
  catch (InvalidStackFrameException ignored) {
  }
  catch(VMDisconnectedException vde) {
  }
}
项目:tools-idea    文件:FramesPanel.java   
protected void rebuild(int event) {
  myRebuildAlarm.cancelAllRequests();
  final boolean isRefresh = event == DebuggerSession.EVENT_REFRESH ||
                            event == DebuggerSession.EVENT_REFRESH_VIEWS_ONLY ||
                            event == DebuggerSession.EVENT_THREADS_REFRESH;
  if (!isRefresh) {
    myPerformFullRebuild.set(true);
  }
  myRebuildAlarm.addRequest(new Runnable() {
    public void run() {
      try {
        doRebuild(!myPerformFullRebuild.getAndSet(false));
      }
      catch (VMDisconnectedException e) {
        // ignored
      }
    }
  }, 100, ModalityState.NON_MODAL);
}
项目:tools-idea    文件:DebuggerTreePanel.java   
protected void rebuild(int event) {
  myRebuildAlarm.cancelAllRequests();
  myRebuildAlarm.addRequest(new Runnable() {
    public void run() {
      try {
        final DebuggerContextImpl context = getContext();
        if(context.getDebuggerSession() != null) {
          getTree().rebuild(context);
        }
      }
      catch (VMDisconnectedException e) {
        // ignored
      }
    }
  }, 100, ModalityState.NON_MODAL);
}
项目:openjdk-jdk7u-jdk    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:openjdk-icedtea7    文件:Session.java   
public void detach() {
    if (!dead) {
        eventSourceThread.interrupt();
        eventSourceThread = null;
        //### The VM may already be disconnected
        //### if the debuggee did a System.exit().
        //### Exception handler here is a kludge,
        //### Rather, there are many other places
        //### where we need to handle this exception,
        //### and initiate a detach due to an error
        //### condition, e.g., connection failure.
        try {
            vm.dispose();
        } catch (VMDisconnectedException ee) {}
        dead = true;
        diagnostics.putString("Disconnected from VM");
    }
}
项目:incubator-netbeans    文件:CallStackFrameImpl.java   
@Override
public boolean equals(Object obj) {
    if (!(obj instanceof EqualsInfo)) {
        return false;
    }
    EqualsInfo ei = (EqualsInfo) obj;
    try {
        return thread == ei.thread &&
               depth == ei.depth &&
               (location == ei.location ||
                location != null && location.equals(ei.location));
    } catch (VMDisconnectedException vmdex) {
        return false;
    }
}
项目:incubator-netbeans    文件:CallStackFrameImpl.java   
@Override
public int hashCode() {
    if (thread == null) return 0;
    try {
        return (thread.hashCode() << 8 + depth + (location != null ? location.hashCode() << 4 : 0));
    } catch (VMDisconnectedException vmdex) {
        return 0;
    }
}
项目:incubator-netbeans    文件:BreakpointImpl.java   
protected EventRequestManager getEventRequestManager () throws VMDisconnectedExceptionWrapper, InternalExceptionWrapper {
    VirtualMachine vm = getVirtualMachine();
    if (vm == null) {
        // Already disconnected
        throw new VMDisconnectedExceptionWrapper(new VMDisconnectedException());
    }
    return VirtualMachineWrapper.eventRequestManager (vm);
}
项目:jdk8u-jdk    文件:NullThreadGroupNameTest.java   
private void assertThreadGroupName(ThreadGroupReference threadGroup, String expectedName) {
    try {
        String name = threadGroup.name();
        if (!expectedName.equals(name)) {
            throw new AssertionError("Unexpected thread group name '" + name + "'");
        }
    } catch (VMDisconnectedException vmde) {
        throw new AssertionError("Likely JVM crash with null thread group name", vmde);
    }
}
项目:openjdk-jdk10    文件:JDWPException.java   
RuntimeException toJDIException() {
    switch (errorCode) {
        case JDWP.Error.INVALID_OBJECT:
            return new ObjectCollectedException();
        case JDWP.Error.INVALID_MODULE:
            return new InvalidModuleException();
        case JDWP.Error.VM_DEAD:
            return new VMDisconnectedException();
        case JDWP.Error.OUT_OF_MEMORY:
            return new VMOutOfMemoryException();
        case JDWP.Error.CLASS_NOT_PREPARED:
            return new ClassNotPreparedException();
        case JDWP.Error.INVALID_FRAMEID:
        case JDWP.Error.NOT_CURRENT_FRAME:
            return new InvalidStackFrameException();
        case JDWP.Error.NOT_IMPLEMENTED:
            return new UnsupportedOperationException();
        case JDWP.Error.INVALID_INDEX:
        case JDWP.Error.INVALID_LENGTH:
            return new IndexOutOfBoundsException();
        case JDWP.Error.TYPE_MISMATCH:
            return new InconsistentDebugInfoException();
        case JDWP.Error.INVALID_THREAD:
            return new IllegalThreadStateException();
        default:
            return new InternalException("Unexpected JDWP Error: " + errorCode, errorCode);
    }
}
项目:openjdk-jdk10    文件:TargetVM.java   
void waitForReply(Packet packet) {
    synchronized(packet) {
        while ((!packet.replied) && shouldListen) {
            try { packet.wait(); } catch (InterruptedException e) {;}
        }

        if (!packet.replied) {
            throw new VMDisconnectedException();
        }
    }
}
项目:openjdk-jdk10    文件:NullThreadGroupNameTest.java   
private void assertThreadGroupName(ThreadGroupReference threadGroup, String expectedName) {
    try {
        String name = threadGroup.name();
        if (!expectedName.equals(name)) {
            throw new AssertionError("Unexpected thread group name '" + name + "'");
        }
    } catch (VMDisconnectedException vmde) {
        throw new AssertionError("Likely JVM crash with null thread group name", vmde);
    }
}
项目:java-debug    文件:Breakpoint.java   
@Override
public void close() throws Exception {
    try {
        vm.eventRequestManager().deleteEventRequests(requests());
    } catch (VMDisconnectedException ex) {
        // ignore since removing breakpoints is meaningless when JVM is terminated.
    }
    subscriptions().forEach(subscription -> {
        subscription.dispose();
    });
    requests.clear();
    subscriptions.clear();
}
项目:java-debug    文件:Breakpoint.java   
private static List<Location> collectLocations(List<ReferenceType> refTypes, int lineNumber, boolean includeNestedTypes) {
    List<Location> locations = new ArrayList<>();
    try {
        refTypes.forEach(refType -> {
            List<Location> newLocations = collectLocations(refType, lineNumber);
            if (!newLocations.isEmpty()) {
                locations.addAll(newLocations);
            } else if (includeNestedTypes) {
                // ReferenceType.nestedTypes() will invoke vm.allClasses() to list all loaded classes,
                // should avoid using nestedTypes for performance.
                for (ReferenceType nestedType : refType.nestedTypes()) {
                    List<Location> nestedLocations = collectLocations(nestedType, lineNumber);
                    if (!nestedLocations.isEmpty()) {
                        locations.addAll(nestedLocations);
                        break;
                    }
                }
            }
        });
    } catch (VMDisconnectedException ex) {
        // collect locations operation may be executing while JVM is terminating, thus the VMDisconnectedException may be
        // possible, in case of VMDisconnectedException, this method will return an empty array which turns out a valid
        // response in vscode, causing no error log in trace.
    }

    return locations;
}
项目:java-debug    文件:DebugUtility.java   
/**
 * Get the available ThreadReference list in the debug session.
 * If the debug session has terminated, return an empty list instead of VMDisconnectedException.
 * @param debugSession
 *                  the debug session
 * @return the available ThreadReference list
 */
public static List<ThreadReference> getAllThreadsSafely(IDebugSession debugSession) {
    if (debugSession != null) {
        try {
            return debugSession.getAllThreads();
        } catch (VMDisconnectedException ex) {
            // do nothing.
        }
    }
    return new ArrayList<>();
}
项目:java-debug    文件:DebugUtility.java   
/**
 * Remove the event request from the vm. If the vm has terminated, do nothing.
 * @param eventManager
 *                  The event request manager.
 * @param request
 *                  The target event request.
 */
public static void deleteEventRequestSafely(EventRequestManager eventManager, EventRequest request) {
    try {
        eventManager.deleteEventRequest(request);
    } catch (VMDisconnectedException ex) {
        // ignore.
    }
}
项目:java-debug    文件:DebugUtility.java   
/**
 * Remove the event request list from the vm. If the vm has terminated, do nothing.
 * @param eventManager
 *                  The event request manager.
 * @param requests
 *                  The target event request list.
 */
public static void deleteEventRequestSafely(EventRequestManager eventManager, List<EventRequest> requests) {
    try {
        eventManager.deleteEventRequests(requests);
    } catch (VMDisconnectedException ex) {
        // ignore.
    }
}
项目:java-debug    文件:DebugSessionFactory.java   
public static void shutdownDebugSession(String projectName) throws Exception {
    try {
        IDebugSession debugSession = debugSessionMap.remove(projectName);
        if (debugSession != null) {
            System.out.println("Shutdown debug session.");
            debugSession.terminate();
        }
    } catch (VMDisconnectedException ex) {
        // ignore
    }
}
项目:openjdk9    文件:NullThreadGroupNameTest.java   
private void assertThreadGroupName(ThreadGroupReference threadGroup, String expectedName) {
    try {
        String name = threadGroup.name();
        if (!expectedName.equals(name)) {
            throw new AssertionError("Unexpected thread group name '" + name + "'");
        }
    } catch (VMDisconnectedException vmde) {
        throw new AssertionError("Likely JVM crash with null thread group name", vmde);
    }
}
项目:jdk8u_jdk    文件:NullThreadGroupNameTest.java   
private void assertThreadGroupName(ThreadGroupReference threadGroup, String expectedName) {
    try {
        String name = threadGroup.name();
        if (!expectedName.equals(name)) {
            throw new AssertionError("Unexpected thread group name '" + name + "'");
        }
    } catch (VMDisconnectedException vmde) {
        throw new AssertionError("Likely JVM crash with null thread group name", vmde);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:NullThreadGroupNameTest.java   
private void assertThreadGroupName(ThreadGroupReference threadGroup, String expectedName) {
    try {
        String name = threadGroup.name();
        if (!expectedName.equals(name)) {
            throw new AssertionError("Unexpected thread group name '" + name + "'");
        }
    } catch (VMDisconnectedException vmde) {
        throw new AssertionError("Likely JVM crash with null thread group name", vmde);
    }
}
项目:intellij-ce-playground    文件:DebuggerTreePanel.java   
@Override
public void run() {
  try {
    final DebuggerContextImpl context = getContext();
    if(context.getDebuggerSession() != null) {
      getTree().rebuild(context);
    }
  }
  catch (VMDisconnectedException ignored) {
  }

}