KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdi > internal > request > EventRequestImpl


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdi.internal.request;
12
13
14 import java.io.ByteArrayOutputStream JavaDoc;
15 import java.io.DataInputStream JavaDoc;
16 import java.io.DataOutputStream JavaDoc;
17 import java.io.IOException JavaDoc;
18 import java.util.ArrayList JavaDoc;
19 import java.util.HashMap JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import org.eclipse.jdi.internal.FieldImpl;
23 import org.eclipse.jdi.internal.LocationImpl;
24 import org.eclipse.jdi.internal.MirrorImpl;
25 import org.eclipse.jdi.internal.ObjectReferenceImpl;
26 import org.eclipse.jdi.internal.ReferenceTypeImpl;
27 import org.eclipse.jdi.internal.ThreadReferenceImpl;
28 import org.eclipse.jdi.internal.VirtualMachineImpl;
29 import org.eclipse.jdi.internal.event.EventImpl;
30 import org.eclipse.jdi.internal.jdwp.JdwpCommandPacket;
31 import org.eclipse.jdi.internal.jdwp.JdwpReplyPacket;
32
33 import com.sun.jdi.InternalException;
34 import com.sun.jdi.ObjectCollectedException;
35 import com.sun.jdi.ObjectReference;
36 import com.sun.jdi.ReferenceType;
37 import com.sun.jdi.ThreadReference;
38 import com.sun.jdi.VMMismatchException;
39 import com.sun.jdi.request.EventRequest;
40 import com.sun.jdi.request.InvalidRequestStateException;
41 import com.sun.jdi.request.StepRequest;
42
43
44 /**
45  * this class implements the corresponding interfaces
46  * declared by the JDI specification. See the com.sun.jdi package
47  * for more information.
48  *
49  */

50 public abstract class EventRequestImpl extends MirrorImpl implements EventRequest {
51     /** Jdwp constants for StepRequests. */
52     public static final byte STEP_SIZE_MIN_JDWP = 0;
53     public static final byte STEP_SIZE_LINE_JDWP = 1;
54     public static final byte STEP_DEPTH_INTO_JDWP = 0;
55     public static final byte STEP_DEPTH_OVER_JDWP = 1;
56     public static final byte STEP_DEPTH_OUT_JDWP = 2;
57     public static final byte STEP_DEPTH_REENTER_JDWP_HCR = 3; // OTI specific for Hot Code Replacement.
58

59     /** Jdwp constants for SuspendPolicy. */
60     public static final byte SUSPENDPOL_NONE_JDWP = 0;
61     public static final byte SUSPENDPOL_EVENT_THREAD_JDWP = 1;
62     public static final byte SUSPENDPOL_ALL_JDWP = 2;
63
64     /** Constants for ModifierKind. */
65     public static final byte MODIF_KIND_COUNT = 1;
66     public static final byte MODIF_KIND_CONDITIONAL = 2;
67     public static final byte MODIF_KIND_THREADONLY = 3;
68     public static final byte MODIF_KIND_CLASSONLY = 4;
69     public static final byte MODIF_KIND_CLASSMATCH = 5;
70     public static final byte MODIF_KIND_CLASSEXCLUDE = 6;
71     public static final byte MODIF_KIND_LOCATIONONLY = 7;
72     public static final byte MODIF_KIND_EXCEPTIONONLY = 8;
73     public static final byte MODIF_KIND_FIELDONLY = 9;
74     public static final byte MODIF_KIND_STEP = 10;
75     public static final byte MODIF_KIND_INSTANCE = 11;
76     public static final byte MODIF_KIND_SOURCE_NAME_FILTER = 12;
77     
78     /** Mapping of command codes to strings. */
79     private static HashMap JavaDoc fStepSizeMap = null;
80     private static HashMap JavaDoc fStepDepthMap = null;
81     private static HashMap JavaDoc fSuspendPolicyMap = null;
82     private static HashMap JavaDoc fModifierKindMap = null;
83
84     /** Flag that indicates the request was generated from inside of this JDI implementation. */
85     private boolean fGeneratedInside = false;
86     
87     /** User property map. */
88     private HashMap JavaDoc fPropertyMap;
89     
90     /** RequestId of EventRequest, assigned by the reply data of the JDWP Event Reuqest Set command, null if request had not yet been enabled. */
91     protected RequestID fRequestID = null;
92     /** Determines the threads to suspend when the requested event occurs in the target VM. */
93     private byte fSuspendPolicy = SUSPEND_ALL; // Default is as specified by JDI spec.
94

95     /**
96      * Modifiers.
97      */

98     /** Count filters. */
99     protected ArrayList JavaDoc fCountFilters;
100     
101     /** Thread filters. */
102     protected ArrayList JavaDoc fThreadFilters = null;
103     
104     /** Class filters. */
105     protected ArrayList JavaDoc fClassFilters = null;
106     
107     /** Class filters. */
108     protected ArrayList JavaDoc fClassFilterRefs = null;
109     
110     /** Class Exclusion filters. */
111     protected ArrayList JavaDoc fClassExclusionFilters = null;
112     
113     /** Location filters. */
114     protected ArrayList JavaDoc fLocationFilters = null;
115     
116     /** Exception filters. */
117     protected ArrayList JavaDoc fExceptionFilters = null;
118     
119     /** Field filters. */
120     protected ArrayList JavaDoc fFieldFilters = null;
121     
122     /** Thread step filters. */
123     protected ArrayList JavaDoc fThreadStepFilters = null;
124     
125     /** Instance filters. */
126     protected ArrayList JavaDoc fInstanceFilters = null;
127     /**
128      * source name filters
129      * @since 3.3
130      */

131     protected ArrayList JavaDoc fSourceNameFilters = null;
132
133     /**
134      * Creates new EventRequest.
135      */

136     protected EventRequestImpl(String JavaDoc description, VirtualMachineImpl vmImpl) {
137         super(description, vmImpl);
138     }
139     
140     /**
141      * @return Returns string representation.
142      */

143     public String JavaDoc toString() {
144         return super.toString() + (fRequestID == null ? RequestMessages.EventRequestImpl___not_enabled__1 : RequestMessages.EventRequestImpl____2 + fRequestID); //
145
}
146     
147     /**
148      * @return Returns the value of the property with the specified key.
149      */

150     public Object JavaDoc getProperty(Object JavaDoc key) {
151         if (fPropertyMap == null) {
152             return null;
153         }
154         
155         return fPropertyMap.get(key);
156     }
157     
158     /**
159      * Add an arbitrary key/value "property" to this request.
160      */

161     public void putProperty(Object JavaDoc key, Object JavaDoc value) {
162         if (fPropertyMap == null)
163             fPropertyMap = new HashMap JavaDoc();
164             
165         if (value == null)
166             fPropertyMap.remove(key);
167         else
168             fPropertyMap.put(key, value);
169     }
170            
171     /**
172      * Sets the generated inside flag. Used for requests that are not generated by JDI requests from outside.
173      */

174     public void setGeneratedInside() {
175         fGeneratedInside = true;
176     }
177     
178     /**
179      * @return Returns whether the event request was generated from inside of this JDI implementation.
180      */

181     public final boolean isGeneratedInside() {
182         return fGeneratedInside;
183     }
184
185     /**
186      * Disables event request.
187      */

188     public synchronized void disable() {
189         if (!isEnabled())
190             return;
191         
192         initJdwpRequest();
193         try {
194             ByteArrayOutputStream JavaDoc outBytes = new ByteArrayOutputStream JavaDoc();
195             DataOutputStream JavaDoc outData = new DataOutputStream JavaDoc(outBytes);
196             writeByte(eventKind(), "event kind", EventImpl.eventKindMap(), outData); //$NON-NLS-1$
197
fRequestID.write(this, outData);
198     
199             JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.ER_CLEAR, outBytes);
200             switch (replyPacket.errorCode()) {
201                 case JdwpReplyPacket.NOT_FOUND:
202                     throw new InvalidRequestStateException();
203             }
204             defaultReplyErrorHandler(replyPacket.errorCode());
205             
206             virtualMachineImpl().eventRequestManagerImpl().removeRequestIDMapping(this);
207             fRequestID = null;
208         } catch (IOException JavaDoc e) {
209             defaultIOExceptionHandler(e);
210         } finally {
211             handledJdwpRequest();
212         }
213     }
214     
215     /**
216      * Enables event request.
217      */

218     public synchronized void enable() {
219         if (isEnabled())
220             return;
221
222         initJdwpRequest();
223         try {
224             ByteArrayOutputStream JavaDoc outBytes = new ByteArrayOutputStream JavaDoc();
225             DataOutputStream JavaDoc outData = new DataOutputStream JavaDoc(outBytes);
226             writeByte(eventKind(), "event kind", EventImpl.eventKindMap(), outData); //$NON-NLS-1$
227
writeByte(suspendPolicyJDWP(), "suspend policy", EventRequestImpl.suspendPolicyMap(), outData); //$NON-NLS-1$
228
writeInt(modifierCount(), "modifiers", outData); //$NON-NLS-1$
229
writeModifiers(outData);
230             
231             JdwpReplyPacket replyPacket = requestVM(JdwpCommandPacket.ER_SET, outBytes);
232             defaultReplyErrorHandler(replyPacket.errorCode());
233             DataInputStream JavaDoc replyData = replyPacket.dataInStream();
234             fRequestID = RequestID.read(this, replyData);
235             virtualMachineImpl().eventRequestManagerImpl().addRequestIDMapping(this);
236         } catch (IOException JavaDoc e) {
237             defaultIOExceptionHandler(e);
238         } finally {
239             handledJdwpRequest();
240         }
241     }
242
243     /**
244      * Clear all breakpoints (used by EventRequestManager).
245      */

246     public static void clearAllBreakpoints(MirrorImpl mirror) {
247         mirror.initJdwpRequest();
248         try {
249             JdwpReplyPacket replyPacket = mirror.requestVM(JdwpCommandPacket.ER_CLEAR_ALL_BREAKPOINTS);
250             mirror.defaultReplyErrorHandler(replyPacket.errorCode());
251         } finally {
252             mirror.handledJdwpRequest();
253         }
254     }
255
256     /**
257      * @return Returns whether event request is enabled.
258      */

259     public synchronized final boolean isEnabled() {
260         return fRequestID != null;
261     }
262
263     /**
264      * Disables or enables event request.
265      */

266     public void setEnabled(boolean enable) {
267         if (enable)
268             enable();
269         else
270             disable();
271     }
272
273     /**
274      * @exception InvalidRequestStateException is thrown if this request is enabled.
275      */

276     public void checkDisabled() throws InvalidRequestStateException {
277         if (isEnabled())
278             throw new InvalidRequestStateException();
279     }
280     
281     /**
282      * Sets suspend policy.
283      */

284     public void setSuspendPolicy(int suspendPolicy) {
285         fSuspendPolicy = (byte)suspendPolicy;
286         if (isEnabled()) {
287             disable();
288             enable();
289         }
290     }
291
292     /**
293      * @return Returns suspend policy.
294      */

295     public int suspendPolicy() {
296         return fSuspendPolicy;
297     }
298
299     /**
300      * @return Returns requestID, or null if request ID is not (yet) assigned.
301      */

302     public final RequestID requestID() {
303         return fRequestID;
304     }
305     
306     /**
307      * Sets countfilter.
308      */

309     public void addCountFilter(int count) throws InvalidRequestStateException {
310         checkDisabled();
311         if (fCountFilters == null)
312             fCountFilters = new ArrayList JavaDoc();
313         
314         fCountFilters.add(new Integer JavaDoc(count));
315     }
316     
317     /**
318      * Restricts reported events to those in the given thread.
319      */

320     public void addThreadFilter(ThreadReference threadFilter) throws ObjectCollectedException, VMMismatchException, InvalidRequestStateException {
321         checkVM(threadFilter);
322         checkDisabled();
323         if (threadFilter.isCollected())
324             throw new ObjectCollectedException();
325         if (fThreadFilters == null)
326             fThreadFilters = new ArrayList JavaDoc();
327             
328         fThreadFilters.add(threadFilter);
329     }
330
331     /**
332      * Restricts the events generated by this request to the preparation of reference types whose name matches this restricted regular expression.
333      */

334     public void addClassFilter(ReferenceType filter) throws VMMismatchException, InvalidRequestStateException {
335         checkVM(filter);
336         checkDisabled();
337         if (fClassFilterRefs == null)
338             fClassFilterRefs = new ArrayList JavaDoc();
339             
340         fClassFilterRefs.add(filter);
341     }
342     
343     /**
344      * Restricts the events generated by this request to be the preparation of the given reference type and any subtypes.
345      */

346     public void addClassFilter(String JavaDoc filter) throws InvalidRequestStateException {
347         checkDisabled();
348         if (fClassFilters == null)
349             fClassFilters = new ArrayList JavaDoc();
350             
351         fClassFilters.add(filter);
352     }
353     
354     /**
355      * Restricts the events generated by this request to the preparation of reference types whose name does not match this restricted regular expression.
356      */

357     public void addClassExclusionFilter(String JavaDoc filter) throws InvalidRequestStateException {
358         checkDisabled();
359         if (fClassExclusionFilters == null)
360             fClassExclusionFilters = new ArrayList JavaDoc();
361             
362         fClassExclusionFilters.add(filter);
363     }
364
365     /**
366      * Restricts the events generated by this request to those that occur at the given location.
367      */

368     public void addLocationFilter(LocationImpl location) throws VMMismatchException {
369         checkDisabled();
370         // Used in createBreakpointRequest.
371
checkVM(location);
372         if (fLocationFilters == null)
373             fLocationFilters = new ArrayList JavaDoc();
374             
375         fLocationFilters.add(location);
376     }
377     
378     /**
379      * Restricts reported exceptions by their class and whether they are caught or uncaught.
380      */

381      public void addExceptionFilter(ReferenceTypeImpl refType, boolean notifyCaught, boolean notifyUncaught) throws VMMismatchException {
382         checkDisabled();
383         // refType Null means report exceptions of all types.
384
if (refType != null)
385             checkVM(refType);
386             
387         if (fExceptionFilters == null)
388             fExceptionFilters = new ArrayList JavaDoc();
389             
390         ExceptionFilter filter = new ExceptionFilter();
391         filter.fException = refType;
392         filter.fNotifyCaught = notifyCaught;
393         filter.fNotifyUncaught = notifyUncaught;
394         fExceptionFilters.add(filter);
395     }
396
397     /**
398      * Restricts reported events to those that occur for a given field.
399      */

400      public void addFieldFilter(FieldImpl field) throws VMMismatchException {
401         checkDisabled();
402         // Used in createXWatchpointRequest methods.
403
checkVM(field);
404         if (fFieldFilters == null)
405             fFieldFilters = new ArrayList JavaDoc();
406             
407         fFieldFilters.add(field);
408     }
409
410     /**
411      * Restricts reported step events to those which satisfy depth and size constraints.
412      */

413      public void addStepFilter(ThreadReferenceImpl thread, int size, int depth) throws VMMismatchException {
414         checkDisabled();
415         // Used in createStepRequest.
416
checkVM(thread);
417         
418         if (fThreadStepFilters == null)
419             fThreadStepFilters = new ArrayList JavaDoc();
420             
421         ThreadStepFilter filter = new ThreadStepFilter();
422         filter.fThread = thread;
423         filter.fThreadStepSize = size;
424         filter.fThreadStepDepth = depth;
425         fThreadStepFilters.add(filter);
426      }
427      
428      /**
429       * Helper method which allows instance filters to be added
430       * @param instance the object ref instance to add to the listing
431       */

432      public void addInstanceFilter(ObjectReference instance) {
433         checkDisabled();
434         checkVM(instance);
435         if (fInstanceFilters == null) {
436             fInstanceFilters = new ArrayList JavaDoc();
437         }
438         fInstanceFilters.add(instance);
439      }
440
441      /**
442       * Adds a source name filter to the request. An exact match or pattern beginning
443       * OR ending in '*'.
444       *
445       * @param pattern source name pattern
446       * @since 3.3
447       */

448      public void addSourceNameFilter(String JavaDoc pattern) {
449          checkDisabled();
450          if(fSourceNameFilters == null) {
451              fSourceNameFilters = new ArrayList JavaDoc();
452          }
453          fSourceNameFilters.add(pattern);
454      }
455      
456     /**
457      * From here on JDWP functionality of EventRequest is implemented.
458      */

459
460     /**
461      * @return Returns JDWP constant for suspend policy.
462      */

463     public byte suspendPolicyJDWP() {
464         switch (fSuspendPolicy) {
465             case SUSPEND_NONE:
466                 return SUSPENDPOL_NONE_JDWP;
467             case SUSPEND_EVENT_THREAD:
468                 return SUSPENDPOL_EVENT_THREAD_JDWP;
469             case SUSPEND_ALL:
470                 return SUSPENDPOL_ALL_JDWP;
471             default:
472                 throw new InternalException(RequestMessages.EventRequestImpl_Invalid_suspend_policy_encountered___3 + fSuspendPolicy);
473         }
474     }
475
476     /**
477      * @return Returns JDWP constant for step size.
478      */

479     public int threadStepSizeJDWP(int threadStepSize) {
480         switch (threadStepSize) {
481             case StepRequest.STEP_MIN:
482                 return STEP_SIZE_MIN_JDWP;
483             case StepRequest.STEP_LINE:
484                 return STEP_SIZE_LINE_JDWP;
485             default:
486                 throw new InternalException(RequestMessages.EventRequestImpl_Invalid_step_size_encountered___4 + threadStepSize);
487         }
488     }
489     
490     /**
491      * @return Returns JDWP constant for step depth.
492      */

493     public int threadStepDepthJDWP(int threadStepDepth) {
494         switch (threadStepDepth) {
495             case StepRequest.STEP_INTO:
496                 return STEP_DEPTH_INTO_JDWP;
497             case StepRequest.STEP_OVER:
498                 return STEP_DEPTH_OVER_JDWP;
499             case StepRequest.STEP_OUT:
500                 return STEP_DEPTH_OUT_JDWP;
501             default:
502                 throw new InternalException(RequestMessages.EventRequestImpl_Invalid_step_depth_encountered___5 + threadStepDepth);
503         }
504     }
505
506     /**
507      * @return Returns JDWP EventKind.
508      */

509     protected abstract byte eventKind();
510
511     /**
512      * @return Returns number of modifiers.
513      */

514     protected int modifierCount() {
515         int count = 0;
516         
517         if (fCountFilters != null)
518             count += fCountFilters.size();
519         if (fThreadFilters != null)
520             count += fThreadFilters.size();
521         if (fClassFilterRefs != null)
522             count += fClassFilterRefs.size();
523         if (fClassFilters != null)
524             count += fClassFilters.size();
525         if (fClassExclusionFilters != null)
526             count += fClassExclusionFilters.size();
527         if (fLocationFilters != null)
528             count += fLocationFilters.size();
529         if (fExceptionFilters != null)
530             count += fExceptionFilters.size();
531         if (fFieldFilters != null)
532             count += fFieldFilters.size();
533         if (fThreadStepFilters != null)
534             count += fThreadStepFilters.size();
535         if (fInstanceFilters != null)
536             count += fInstanceFilters.size();
537         if(fSourceNameFilters != null) {
538             if (supportsSourceNameFilters()) {
539                 count += fSourceNameFilters.size();
540             }
541         }
542         return count;
543     }
544
545     /**
546      * Writes JDWP bytestream representation of modifiers.
547      */

548     protected void writeModifiers(DataOutputStream JavaDoc outData) throws IOException JavaDoc {
549         // Note: for some reason the order of these modifiers matters when communicating with SUN's VM.
550
// It seems to expect them 'the wrong way around'.
551
if (fThreadStepFilters != null) {
552             for (int i = 0; i < fThreadStepFilters.size(); i++) {
553                 ThreadStepFilter filter = (ThreadStepFilter)fThreadStepFilters.get(i);
554                 writeByte(MODIF_KIND_STEP, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
555
filter.fThread.write(this, outData);
556                 writeInt(threadStepSizeJDWP(filter.fThreadStepSize), "step size", outData); //$NON-NLS-1$
557
writeInt(threadStepDepthJDWP(filter.fThreadStepDepth), "step depth", outData); //$NON-NLS-1$
558
}
559         }
560         if (fFieldFilters != null) {
561             for (int i = 0; i < fFieldFilters.size(); i++) {
562                 writeByte(MODIF_KIND_FIELDONLY, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
563
((FieldImpl)fFieldFilters.get(i)).writeWithReferenceType(this, outData);
564             }
565         }
566         if (fExceptionFilters != null) {
567             for (int i = 0; i < fExceptionFilters.size(); i++) {
568                 ExceptionFilter filter = (ExceptionFilter)fExceptionFilters.get(i);
569                 writeByte(MODIF_KIND_EXCEPTIONONLY, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
570
if (filter.fException != null)
571                     filter.fException.write(this, outData);
572                 else
573                     ReferenceTypeImpl.writeNull(this, outData);
574     
575                 writeBoolean(filter.fNotifyCaught, "notify caught", outData); //$NON-NLS-1$
576
writeBoolean(filter.fNotifyUncaught, "notify uncaught", outData); //$NON-NLS-1$
577
}
578         }
579         if (fLocationFilters != null) {
580             for (int i = 0; i < fLocationFilters.size(); i++) {
581                 writeByte(MODIF_KIND_LOCATIONONLY, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
582
((LocationImpl)fLocationFilters.get(i)).write(this, outData);
583             }
584         }
585         if (fClassExclusionFilters != null) {
586             for (int i = 0; i < fClassExclusionFilters.size(); i++) {
587                 writeByte(MODIF_KIND_CLASSEXCLUDE, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
588
writeString((String JavaDoc)fClassExclusionFilters.get(i), "class excl. filter", outData); //$NON-NLS-1$
589
}
590         }
591         if (fClassFilters != null) {
592             for (int i = 0; i < fClassFilters.size(); i++) {
593                 writeByte(MODIF_KIND_CLASSMATCH, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
594
writeString((String JavaDoc)fClassFilters.get(i), "class filter", outData); //$NON-NLS-1$
595
}
596         }
597         if (fClassFilterRefs != null) {
598             for (int i = 0; i < fClassFilterRefs.size(); i++) {
599                 writeByte(MODIF_KIND_CLASSONLY, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
600
((ReferenceTypeImpl)fClassFilterRefs.get(i)).write(this, outData);
601             }
602         }
603         if (fThreadFilters != null) {
604             for (int i = 0; i < fThreadFilters.size(); i++) {
605                 writeByte(MODIF_KIND_THREADONLY, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
606
((ThreadReferenceImpl)fThreadFilters.get(i)).write(this, outData);
607             }
608         }
609         if (fCountFilters != null) {
610             for (int i = 0; i < fCountFilters.size(); i++) {
611                 writeByte(MODIF_KIND_COUNT, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
612
writeInt(((Integer JavaDoc)fCountFilters.get(i)).intValue(), "count filter", outData); //$NON-NLS-1$
613
}
614         }
615         if (fInstanceFilters != null) {
616             for (int i = 0; i < fInstanceFilters.size(); i++) {
617                 writeByte(MODIF_KIND_INSTANCE, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
618
((ObjectReferenceImpl)fInstanceFilters.get(i)).write(this, outData);
619             }
620         }
621         if(fSourceNameFilters != null) {
622             if (supportsSourceNameFilters()) {
623                 for (int i = 0; i < fSourceNameFilters.size(); i++) {
624                     writeByte(MODIF_KIND_SOURCE_NAME_FILTER, "modifier", modifierKindMap(), outData); //$NON-NLS-1$
625
writeString((String JavaDoc)fSourceNameFilters.get(i), "modifier", outData); //$NON-NLS-1$
626
}
627             }
628         }
629     }
630
631     /**
632      * Returns whether JDWP supports source name filters (a 1.6 feature).
633      *
634      * @return whether JDWP supports source name filters
635      */

636     private boolean supportsSourceNameFilters() {
637         return ((VirtualMachineImpl)virtualMachine()).isJdwpVersionGreaterOrEqual(1, 6);
638     }
639
640     /**
641      * Retrieves constant mappings.
642      */

643     public static void getConstantMaps() {
644         if (fStepSizeMap != null)
645             return;
646         
647         java.lang.reflect.Field JavaDoc[] fields = EventRequestImpl.class.getDeclaredFields();
648         fStepSizeMap = new HashMap JavaDoc();
649         fStepDepthMap = new HashMap JavaDoc();
650         fSuspendPolicyMap = new HashMap JavaDoc();
651         fModifierKindMap = new HashMap JavaDoc();
652         for (int i = 0; i < fields.length; i++) {
653             java.lang.reflect.Field JavaDoc field = fields[i];
654             if ((field.getModifiers() & java.lang.reflect.Modifier.PUBLIC) == 0 || (field.getModifiers() & java.lang.reflect.Modifier.STATIC) == 0 || (field.getModifiers() & java.lang.reflect.Modifier.FINAL) == 0)
655                 continue;
656                 
657             try {
658                 String JavaDoc name = field.getName();
659                 Integer JavaDoc intValue = new Integer JavaDoc(field.getInt(null));
660                 if (name.startsWith("STEP_SIZE_")) { //$NON-NLS-1$
661
name = name.substring(10);
662                     fStepSizeMap.put(intValue, name);
663                 } else if (name.startsWith("STEP_DEPTH_")) { //$NON-NLS-1$
664
name = name.substring(11);
665                     fStepDepthMap.put(intValue, name);
666                 } else if (name.startsWith("SUSPENDPOL_")) { //$NON-NLS-1$
667
name = name.substring(11);
668                     fSuspendPolicyMap.put(intValue, name);
669                 } else if (name.startsWith("MODIF_KIND_")) { //$NON-NLS-1$
670
name = name.substring(11);
671                     fModifierKindMap.put(intValue, name);
672                 }
673             } catch (IllegalAccessException JavaDoc e) {
674                 // Will not occur for own class.
675
} catch (IllegalArgumentException JavaDoc e) {
676                 // Should not occur.
677
// We should take care that all public static final constants
678
// in this class are numbers that are convertible to int.
679
}
680         }
681     }
682     
683     /**
684      * @return Returns a map with string representations of tags.
685      */

686      public static Map JavaDoc stepSizeMap() {
687         getConstantMaps();
688         return fStepSizeMap;
689      }
690
691     /**
692      * @return Returns a map with string representations of tags.
693      */

694      public static Map JavaDoc stepDepthMap() {
695         getConstantMaps();
696         return fStepDepthMap;
697      }
698
699     /**
700      * @return Returns a map with string representations of type tags.
701      */

702      public static Map JavaDoc suspendPolicyMap() {
703         getConstantMaps();
704         return fSuspendPolicyMap;
705      }
706      
707     /**
708      * @return Returns a map with string representations of type tags.
709      */

710      public static Map JavaDoc modifierKindMap() {
711         getConstantMaps();
712         return fModifierKindMap;
713      }
714
715     class ExceptionFilter {
716         /** If non-null, specifies that exceptions which are instances of fExceptionFilterRef will be reported. */
717         ReferenceTypeImpl fException = null;
718         /** If true, caught exceptions will be reported. */
719         boolean fNotifyCaught = false;
720         /** If true, uncaught exceptions will be reported. */
721         boolean fNotifyUncaught = false;
722     }
723     
724     class ThreadStepFilter {
725         /** ThreadReference of thread in which to step. */
726         protected ThreadReferenceImpl fThread = null;
727         /** Size of each step. */
728         protected int fThreadStepSize;
729         /** Relative call stack limit. */
730         protected int fThreadStepDepth;
731     }
732 }
733
Popular Tags