Java Code Examples for com.sun.jdi.request.EventRequestManager#deleteEventRequests()
The following examples show how to use
com.sun.jdi.request.EventRequestManager#deleteEventRequests() .
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: DebugSession.java From java-debug with Eclipse Public License 1.0 | 5 votes |
@Override public void setExceptionBreakpoints(boolean notifyCaught, boolean notifyUncaught, String[] classFilters, String[] classExclusionFilters) { EventRequestManager manager = vm.eventRequestManager(); ArrayList<ExceptionRequest> legacy = new ArrayList<>(manager.exceptionRequests()); manager.deleteEventRequests(legacy); // When no exception breakpoints are requested, no need to create an empty exception request. if (notifyCaught || notifyUncaught) { // from: https://www.javatips.net/api/REPLmode-master/src/jm/mode/replmode/REPLRunner.java // Calling this seems to set something internally to make the // Eclipse JDI wake up. Without it, an ObjectCollectedException // is thrown on request.enable(). No idea why this works, // but at least exception handling has returned. (Suspect that it may // block until all or at least some threads are available, meaning // that the app has launched and we have legit objects to talk to). vm.allThreads(); // The bug may not have been noticed because the test suite waits for // a thread to be available, and queries it by calling allThreads(). // See org.eclipse.debug.jdi.tests.AbstractJDITest for the example. // get only the uncaught exceptions ExceptionRequest request = manager.createExceptionRequest(null, notifyCaught, notifyUncaught); request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); if (classFilters != null) { for (String classFilter : classFilters) { request.addClassFilter(classFilter); } } if (classExclusionFilters != null) { for (String exclusionFilter : classExclusionFilters) { request.addClassExclusionFilter(exclusionFilter); } } request.enable(); } }
Example 2
Source File: DebugUtility.java From java-debug with Eclipse Public License 1.0 | 5 votes |
/** * 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 3
Source File: VirtualMachineImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 4
Source File: VirtualMachineImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 5
Source File: VirtualMachineImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 6
Source File: VirtualMachineImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 7
Source File: VirtualMachineImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 8
Source File: VirtualMachineImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 9
Source File: VirtualMachineImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 10
Source File: VirtualMachineImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 11
Source File: VirtualMachineImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 12
Source File: VirtualMachineImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 13
Source File: VirtualMachineImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 14
Source File: VirtualMachineImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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(); } }
Example 15
Source File: VirtualMachineImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
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(); } }