1 7 34 35 package com.sun.tools.example.debug.bdi; 36 37 import com.sun.jdi.*; 38 import com.sun.jdi.request.*; 39 40 import java.util.*; 41 42 class EventRequestSpecList { 43 44 private List eventRequestSpecs = Collections.synchronizedList( 46 new ArrayList()); 47 48 final ExecutionManager runtime; 49 50 EventRequestSpecList(ExecutionManager runtime) { 51 this.runtime = runtime; 52 } 53 54 57 void resolve(ReferenceType refType) { 58 synchronized(eventRequestSpecs) { 59 Iterator iter = eventRequestSpecs.iterator(); 60 while (iter.hasNext()) { 61 ((EventRequestSpec)iter.next()).attemptResolve(refType); 62 } 63 } 64 } 65 66 void install(EventRequestSpec ers, VirtualMachine vm) { 67 synchronized (eventRequestSpecs) { 68 eventRequestSpecs.add(ers); 69 } 70 if (vm != null) { 71 ers.attemptImmediateResolve(vm); 72 } 73 } 74 75 BreakpointSpec 76 createClassLineBreakpoint(String classPattern, int line) { 77 ReferenceTypeSpec refSpec = 78 new PatternReferenceTypeSpec(classPattern); 79 return new LineBreakpointSpec(this, refSpec, line); 80 } 81 82 BreakpointSpec 83 createSourceLineBreakpoint(String sourceName, int line) { 84 ReferenceTypeSpec refSpec = 85 new SourceNameReferenceTypeSpec(sourceName, line); 86 return new LineBreakpointSpec(this, refSpec, line); 87 } 88 89 BreakpointSpec 90 createMethodBreakpoint(String classPattern, 91 String methodId, List methodArgs) { 92 ReferenceTypeSpec refSpec = 93 new PatternReferenceTypeSpec(classPattern); 94 return new MethodBreakpointSpec(this, refSpec, 95 methodId, methodArgs); 96 } 97 98 ExceptionSpec 99 createExceptionIntercept(String classPattern, 100 boolean notifyCaught, 101 boolean notifyUncaught) { 102 ReferenceTypeSpec refSpec = 103 new PatternReferenceTypeSpec(classPattern); 104 return new ExceptionSpec(this, refSpec, 105 notifyCaught, notifyUncaught); 106 } 107 108 AccessWatchpointSpec 109 createAccessWatchpoint(String classPattern, String fieldId) { 110 ReferenceTypeSpec refSpec = 111 new PatternReferenceTypeSpec(classPattern); 112 return new AccessWatchpointSpec(this, refSpec, fieldId); 113 } 114 115 ModificationWatchpointSpec 116 createModificationWatchpoint(String classPattern, String fieldId) { 117 ReferenceTypeSpec refSpec = 118 new PatternReferenceTypeSpec(classPattern); 119 return new ModificationWatchpointSpec(this, refSpec, fieldId); 120 } 121 122 void delete(EventRequestSpec ers) { 123 EventRequest request = ers.getEventRequest(); 124 synchronized (eventRequestSpecs) { 125 eventRequestSpecs.remove(ers); 126 } 127 if (request != null) { 128 request.virtualMachine().eventRequestManager() 129 .deleteEventRequest(request); 130 } 131 notifyDeleted(ers); 132 } 134 135 List eventRequestSpecs() { 136 synchronized (eventRequestSpecs) { 138 return new ArrayList(eventRequestSpecs); 139 } 140 } 141 142 144 private Vector specListeners() { 145 return (Vector)runtime.specListeners.clone(); 146 } 147 148 void notifySet(EventRequestSpec spec) { 149 Vector l = specListeners(); 150 SpecEvent evt = new SpecEvent(spec); 151 for (int i = 0; i < l.size(); i++) { 152 spec.notifySet((SpecListener)l.elementAt(i), evt); 153 } 154 } 155 156 void notifyDeferred(EventRequestSpec spec) { 157 Vector l = specListeners(); 158 SpecEvent evt = new SpecEvent(spec); 159 for (int i = 0; i < l.size(); i++) { 160 spec.notifyDeferred((SpecListener)l.elementAt(i), evt); 161 } 162 } 163 164 void notifyDeleted(EventRequestSpec spec) { 165 Vector l = specListeners(); 166 SpecEvent evt = new SpecEvent(spec); 167 for (int i = 0; i < l.size(); i++) { 168 spec.notifyDeleted((SpecListener)l.elementAt(i), evt); 169 } 170 } 171 172 void notifyResolved(EventRequestSpec spec) { 173 Vector l = specListeners(); 174 SpecEvent evt = new SpecEvent(spec); 175 for (int i = 0; i < l.size(); i++) { 176 spec.notifyResolved((SpecListener)l.elementAt(i), evt); 177 } 178 } 179 180 void notifyError(EventRequestSpec spec, Exception exc) { 181 Vector l = specListeners(); 182 SpecErrorEvent evt = new SpecErrorEvent(spec, exc); 183 for (int i = 0; i < l.size(); i++) { 184 spec.notifyError((SpecListener)l.elementAt(i), evt); 185 } 186 } 187 } 188 189 190 191 | Popular Tags |