com.sun.jdi.VMDisconnectedException Java Examples

The following examples show how to use com.sun.jdi.VMDisconnectedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Session.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #2
Source File: ThreadsRequestHandler.java    From java-debug with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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());
    }
}
 
Example #3
Source File: Session.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #4
Source File: Session.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #5
Source File: Session.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #6
Source File: Session.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #7
Source File: MyExecutionControl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
        }
    }
}
 
Example #8
Source File: Session.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #9
Source File: Session.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #10
Source File: JPDAClassTypeImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #11
Source File: Session.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #12
Source File: CallStackFrameImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #13
Source File: VisualDebuggerListener.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #14
Source File: Session.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #15
Source File: Session.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #16
Source File: Session.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #17
Source File: Session.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
}
 
Example #18
Source File: DebugUtility.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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.
    }
}
 
Example #19
Source File: NullThreadGroupNameTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #20
Source File: DebugSessionFactory.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
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
    }
}
 
Example #21
Source File: JavaHotCodeReplaceProvider.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns VirtualMachine.classesByName(String), logging any JDI exceptions.
 *
 * @see com.sun.jdi.VirtualMachine
 */
private List<ReferenceType> getJdiClassesByName(String className) {
    try {
        VirtualMachine vm = this.currentDebugSession.getVM();
        if (vm != null) {
            return vm.classesByName(className);
        }
    } catch (VMDisconnectedException ex) {
        // Ignore this exception since it will happen when the VM is still running.
    }
    return Collections.emptyList();
}
 
Example #22
Source File: NullThreadGroupNameTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #23
Source File: NullThreadGroupNameTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #24
Source File: NullThreadGroupNameTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #25
Source File: NullThreadGroupNameTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #26
Source File: NullThreadGroupNameTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #27
Source File: NullThreadGroupNameTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #28
Source File: DebugUtility.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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<>();
}
 
Example #29
Source File: NullThreadGroupNameTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #30
Source File: NullThreadGroupNameTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}