Search in sources :

Example 11 with EventRequestManager

use of com.sun.jdi.request.EventRequestManager in project jdk8u_jdk by JetBrains.

the class VirtualMachineImpl method redefineClasses.

public void redefineClasses(Map<? extends ReferenceType, byte[]> classToBytes) {
    int cnt = classToBytes.size();
    JDWP.VirtualMachine.RedefineClasses.ClassDef[] defs = new JDWP.VirtualMachine.RedefineClasses.ClassDef[cnt];
    validateVM();
    if (!canRedefineClasses()) {
        throw new UnsupportedOperationException();
    }
    Iterator<?> it = classToBytes.entrySet().iterator();
    for (int i = 0; it.hasNext(); i++) {
        Map.Entry<?, ?> entry = (Map.Entry) it.next();
        ReferenceTypeImpl refType = (ReferenceTypeImpl) entry.getKey();
        validateMirror(refType);
        defs[i] = new JDWP.VirtualMachine.RedefineClasses.ClassDef(refType, (byte[]) entry.getValue());
    }
    // flush caches and disable caching until the next suspend
    vm.state().thaw();
    try {
        JDWP.VirtualMachine.RedefineClasses.process(vm, defs);
    } catch (JDWPException exc) {
        switch(exc.errorCode()) {
            case JDWP.Error.INVALID_CLASS_FORMAT:
                throw new ClassFormatError("class not in class file format");
            case JDWP.Error.CIRCULAR_CLASS_DEFINITION:
                throw new ClassCircularityError("circularity has been detected while initializing a class");
            case JDWP.Error.FAILS_VERIFICATION:
                throw new VerifyError("verifier detected internal inconsistency or security problem");
            case JDWP.Error.UNSUPPORTED_VERSION:
                throw new UnsupportedClassVersionError("version numbers of class are not supported");
            case JDWP.Error.ADD_METHOD_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("add method not implemented");
            case JDWP.Error.SCHEMA_CHANGE_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("schema change not implemented");
            case JDWP.Error.HIERARCHY_CHANGE_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("hierarchy change not implemented");
            case JDWP.Error.DELETE_METHOD_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("delete method not implemented");
            case JDWP.Error.CLASS_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("changes to class modifiers not implemented");
            case JDWP.Error.METHOD_MODIFIERS_CHANGE_NOT_IMPLEMENTED:
                throw new UnsupportedOperationException("changes to method modifiers not implemented");
            case JDWP.Error.NAMES_DONT_MATCH:
                throw new NoClassDefFoundError("class names do not match");
            default:
                throw exc.toJDIException();
        }
    }
    // Delete any record of the breakpoints
    List<BreakpointRequest> toDelete = new ArrayList<BreakpointRequest>();
    EventRequestManager erm = eventRequestManager();
    it = erm.breakpointRequests().iterator();
    while (it.hasNext()) {
        BreakpointRequest req = (BreakpointRequest) it.next();
        if (classToBytes.containsKey(req.location().declaringType())) {
            toDelete.add(req);
        }
    }
    erm.deleteEventRequests(toDelete);
    // Invalidate any information cached for the classes just redefined.
    it = classToBytes.keySet().iterator();
    while (it.hasNext()) {
        ReferenceTypeImpl rti = (ReferenceTypeImpl) it.next();
        rti.noticeRedefineClass();
    }
}
Also used : BreakpointRequest(com.sun.jdi.request.BreakpointRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager)

Aggregations

EventRequestManager (com.sun.jdi.request.EventRequestManager)11 BreakpointRequest (com.sun.jdi.request.BreakpointRequest)4 EventRequest (com.sun.jdi.request.EventRequest)3 MethodReturnValueWatcher (com.intellij.debugger.engine.requests.MethodReturnValueWatcher)2 RequestManagerImpl (com.intellij.debugger.engine.requests.RequestManagerImpl)2 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)2 AbsentInformationException (com.sun.jdi.AbsentInformationException)2 StepRequest (com.sun.jdi.request.StepRequest)2 IOException (java.io.IOException)2 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)2 Patches (com.intellij.Patches)1 com.intellij.debugger (com.intellij.debugger)1 DebuggerAction (com.intellij.debugger.actions.DebuggerAction)1 DebuggerActions (com.intellij.debugger.actions.DebuggerActions)1 com.intellij.debugger.engine.evaluation (com.intellij.debugger.engine.evaluation)1 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 ThreadReferenceProxy (com.intellij.debugger.engine.jdi.ThreadReferenceProxy)1 com.intellij.debugger.impl (com.intellij.debugger.impl)1