Cleanup event request API
- Restricts event creation through EventBuilder
- Removes unused event-related methods from VmMirror class
Test: art/tools/run-jdwp-tests.sh --mode=host --variant=X64
Change-Id: Ib36b5f7ff5fffe20502225e65d6d967343f85e96
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Event.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Event.java
index 74adafe..6bd47a3 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Event.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Event.java
@@ -25,35 +25,30 @@
*/
package org.apache.harmony.jpda.tests.framework.jdwp;
+import java.util.Collections;
+import java.util.List;
+
/**
* This class provides description of event request.
*/
public class Event {
- public byte eventKind;
- public byte suspendPolicy;
+ public static EventBuilder builder(byte eventKind, byte suspendPolicy) {
+ return new EventBuilder(eventKind, suspendPolicy);
+ }
+
+ public final byte eventKind;
+ public final byte suspendPolicy;
/** List of event modifiers. */
- public EventMod[] mods;
- public int modifiers;
-
- /**
- * Creates new instance with empty data.
- */
- public Event() {
- eventKind = 0;
- suspendPolicy = 0;
- modifiers = -1;
- mods = null;
- }
+ public final List<EventMod> mods;
/**
* Create new instance with specified data.
*/
- public Event(byte eventKind, byte suspendPolicy, EventMod[] mods) {
+ Event(byte eventKind, byte suspendPolicy, List<EventMod> mods) {
this.eventKind = eventKind;
this.suspendPolicy = suspendPolicy;
- this.modifiers = mods.length;
- this.mods = mods;
+ this.mods = Collections.unmodifiableList(mods);
}
}
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventBuilder.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventBuilder.java
index 1e8fd00..cf49bff 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventBuilder.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventBuilder.java
@@ -29,7 +29,7 @@
private final byte suspendPolicy;
private final List<EventMod> modifiers = new ArrayList<EventMod>();
- public EventBuilder(byte eventKind, byte suspendPolicy) {
+ EventBuilder(byte eventKind, byte suspendPolicy) {
this.eventKind = eventKind;
this.suspendPolicy = suspendPolicy;
}
@@ -41,7 +41,7 @@
* @return a reference to this object
*/
public EventBuilder setCount(int count) {
- EventMod mod = createModifier(EventMod.ModKind.Count);
+ EventMod mod = new EventMod(EventMod.ModKind.Count);
mod.count = count;
modifiers.add(mod);
return this;
@@ -54,20 +54,46 @@
* @return a reference to this object
*/
public EventBuilder setThreadOnly(long thread) {
- EventMod mod = createModifier(EventMod.ModKind.ThreadOnly);
+ EventMod mod = new EventMod(EventMod.ModKind.ThreadOnly);
mod.thread = thread;
modifiers.add(mod);
return this;
}
/**
+ * Sets the ClassOnly modifier.
+ *
+ * @param classId the required class ID
+ * @return a reference to this object
+ */
+ public EventBuilder setClassOnly(long classId) {
+ EventMod mod = new EventMod(EventMod.ModKind.ClassOnly);
+ mod.clazz = classId;
+ modifiers.add(mod);
+ return this;
+ }
+
+ /**
* Sets the ClassMatch modifier.
*
* @param pattern the required class pattern
* @return a reference to this object
*/
public EventBuilder setClassMatch(String pattern) {
- EventMod mod = createModifier(EventMod.ModKind.ClassMatch);
+ EventMod mod = new EventMod(EventMod.ModKind.ClassMatch);
+ mod.classPattern = pattern;
+ modifiers.add(mod);
+ return this;
+ }
+
+ /**
+ * Sets the ClassExclude modifier.
+ *
+ * @param pattern the required class pattern
+ * @return a reference to this object
+ */
+ public EventBuilder setClassExclude(String pattern) {
+ EventMod mod = new EventMod(EventMod.ModKind.ClassExclude);
mod.classPattern = pattern;
modifiers.add(mod);
return this;
@@ -80,7 +106,7 @@
* @return a reference to this object
*/
public EventBuilder setLocationOnly(Location location) {
- EventMod mod = createModifier(EventMod.ModKind.LocationOnly);
+ EventMod mod = new EventMod(EventMod.ModKind.LocationOnly);
mod.loc = location;
modifiers.add(mod);
return this;
@@ -96,7 +122,7 @@
*/
public EventBuilder setExceptionOnly(long exceptionClassID, boolean caught,
boolean uncaught) {
- EventMod mod = createModifier(EventMod.ModKind.ExceptionOnly);
+ EventMod mod = new EventMod(EventMod.ModKind.ExceptionOnly);
mod.caught = caught;
mod.uncaught = uncaught;
mod.exceptionOrNull = exceptionClassID;
@@ -112,7 +138,7 @@
* @return a reference to this object
*/
public EventBuilder setFieldOnly(long typeID, long fieldID) {
- EventMod mod = createModifier(EventMod.ModKind.FieldOnly);
+ EventMod mod = new EventMod(EventMod.ModKind.FieldOnly);
mod.declaring = typeID;
mod.fieldID = fieldID;
modifiers.add(mod);
@@ -120,32 +146,54 @@
}
/**
+ * Sets the Step modifier.
+ *
+ * @param threadID the thread where to step
+ * @param stepSize the size of the step
+ * @param stepDepth the depth of the step
+ * @return a reference to this object
+ */
+ public EventBuilder setStep(long threadID, int stepSize, int stepDepth) {
+ EventMod mod = new EventMod(EventMod.ModKind.Step);
+ mod.thread = threadID;
+ mod.size = stepSize;
+ mod.depth = stepDepth;
+ modifiers.add(mod);
+ return this;
+ }
+
+ /**
* Sets the InstanceOnly modifier.
*
* @param instance the required object ID
* @return a reference to this object
*/
public EventBuilder setInstanceOnly(long instance) {
- EventMod mod = createModifier(EventMod.ModKind.InstanceOnly);
+ EventMod mod = new EventMod(EventMod.ModKind.InstanceOnly);
mod.instance = instance;
modifiers.add(mod);
return this;
}
/**
+ * Sets the SourceNameMatch modifier.
+ *
+ * @param sourceNamePattern the source name pattern to match
+ * @return a reference to this object
+ */
+ public EventBuilder setSourceNameMatch(String sourceNamePattern) {
+ EventMod mod = new EventMod(EventMod.ModKind.SourceNameMatch);
+ mod.sourceNamePattern = sourceNamePattern;
+ modifiers.add(mod);
+ return this;
+ }
+
+ /**
* Builds the event with all added modifiers.
*
* @return an {@link Event}
*/
public Event build() {
- EventMod[] mods = new EventMod[modifiers.size()];
- mods = modifiers.toArray(mods);
- return new Event(eventKind, suspendPolicy, mods);
- }
-
- private static EventMod createModifier(byte modifierKind) {
- EventMod mod = new EventMod();
- mod.modKind = modifierKind;
- return mod;
+ return new Event(eventKind, suspendPolicy, modifiers);
}
}
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java
index 71a8560..0b831f0 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/EventMod.java
@@ -59,7 +59,8 @@
public static final byte SourceNameMatch = 12;
}
- public byte modKind;
+ public final byte modKind;
+
public int count;
public int exprID;
@@ -98,8 +99,8 @@
/**
* Creates new instance with empty data.
*/
- public EventMod() {
- modKind = 0;
+ EventMod(byte modKind) {
+ this.modKind = modKind;
count = -1;
exprID = -1;
// threadID
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java
index b992bd6..27f0e57 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java
@@ -98,52 +98,13 @@
}
/**
- * Sets breakpoint to given location.
- *
- * @param typeTag
- * @param breakpoint
- * @return ReplyPacket for corresponding command
- */
- public ReplyPacket setBreakpoint(byte typeTag, Breakpoint breakpoint) {
-
- return setBreakpoint(typeTag, breakpoint,
- JDWPConstants.SuspendPolicy.ALL);
- }
-
- /**
- * Sets breakpoint to given location.
- *
- * @param typeTag
- * @param breakpoint
- * @param suspendPolicy
- * Suspend policy for a breakpoint being created
- * @return ReplyPacket for corresponding command
- */
- public ReplyPacket setBreakpoint(byte typeTag, Breakpoint breakpoint,
- byte suspendPolicy) {
- // Get Class reference ID
- long typeID = getTypeID(breakpoint.className, typeTag);
-
- // Get Method reference ID
- long methodID = getMethodID(typeID, breakpoint.methodName);
-
- // Fill location
- Location location = new Location(typeTag, typeID, methodID,
- breakpoint.index);
-
- // Set breakpoint
- return setBreakpoint(location, suspendPolicy);
- }
-
- /**
- * Sets breakpoint to given location.
- *
+ * Sets breakpoint to given location with suspend policy ALL.
+ *
* @param location
* Location of breakpoint
* @return ReplyPacket for corresponding command
*/
public ReplyPacket setBreakpoint(Location location) {
-
return setBreakpoint(location, JDWPConstants.SuspendPolicy.ALL);
}
@@ -157,17 +118,9 @@
* @return ReplyPacket for corresponding command
*/
public ReplyPacket setBreakpoint(Location location, byte suspendPolicy) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.BREAKPOINT;
-
- // EventMod[] mods = new EventMod[1];
- EventMod[] mods = new EventMod[] { new EventMod() };
-
- mods[0].loc = location;
- mods[0].modKind = EventMod.ModKind.LocationOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set breakpoint
+ Event event = Event.builder(JDWPConstants.EventKind.BREAKPOINT, suspendPolicy)
+ .setLocationOnly(location)
+ .build();
return setEvent(event);
}
@@ -187,30 +140,19 @@
public ReplyPacket setCountableBreakpoint(byte typeTag,
Breakpoint breakpoint, byte suspendPolicy, int count) {
long typeID = getTypeID(breakpoint.className, typeTag);
-
- // Get Method reference ID
long methodID = getMethodID(typeID, breakpoint.methodName);
- byte eventKind = JDWPConstants.EventKind.BREAKPOINT;
-
- EventMod mod1 = new EventMod();
- mod1.modKind = EventMod.ModKind.LocationOnly;
- mod1.loc = new Location(typeTag, typeID, methodID, breakpoint.index);
-
- EventMod mod2 = new EventMod();
- mod2.modKind = EventMod.ModKind.Count;
- mod2.count = count;
-
- EventMod[] mods = new EventMod[] { mod1, mod2 };
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set breakpoint
+ Event event = Event.builder(JDWPConstants.EventKind.BREAKPOINT, suspendPolicy)
+ .setLocationOnly(new Location(typeTag, typeID, methodID, breakpoint.index))
+ .setCount(count)
+ .build();
return setEvent(event);
}
/**
- * Sets breakpoint at the beginning of method with name <i>methodName</i>.
- *
+ * Sets breakpoint at the beginning of method with name <i>methodName</i> with suspend policy
+ * ALL.
+ *
* @param classID
* id of class with required method
* @param methodName
@@ -993,8 +935,8 @@
}
/**
- * Sets ClassPrepare event request for given class name pattern.
- *
+ * Sets ClassPrepare event request for given class name pattern with suspend policy ALL.
+ *
* @param classRegexp
* Required class pattern. Matches are limited to exact matches
* of the given class pattern and matches of patterns that begin
@@ -1002,43 +944,25 @@
* @return ReplyPacket for setting request.
*/
public ReplyPacket setClassPrepared(String classRegexp) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.CLASS_PREPARE;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- // EventMod[] mods = new EventMod[1];
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].classPattern = classRegexp;
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassMatchEvent(JDWPConstants.EventKind.CLASS_PREPARE,
+ JDWPConstants.SuspendPolicy.ALL, classRegexp);
}
/**
- * Set ClassPrepare event request for given class ID.
- *
+ * Set ClassPrepare event request for given class ID with suspend policy ALL.
+ *
* @param referenceTypeID
* class referenceTypeID
* @return ReplyPacket for setting request
*/
public ReplyPacket setClassPrepared(long referenceTypeID) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.CLASS_PREPARE;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- // EventMod[] mods = new EventMod[1];
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].clazz = referenceTypeID;
- mods[0].modKind = EventMod.ModKind.ClassOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassOnlyEvent(JDWPConstants.EventKind.CLASS_PREPARE,
+ JDWPConstants.SuspendPolicy.ALL, referenceTypeID);
}
/**
- * Sets ClassPrepare event request for given source name pattern.
- *
+ * Sets ClassPrepare event request for given source name pattern with suspend policy ALL.
+ *
* @param sourceNamePattern
* Required source name pattern. Matches are limited to exact matches
* of the given source name pattern and matches of patterns that begin
@@ -1046,63 +970,41 @@
* @return ReplyPacket for setting request.
*/
public ReplyPacket setClassPreparedForSourceNameMatch(String sourceNamePattern) {
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.CLASS_PREPARE;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].sourceNamePattern = sourceNamePattern;
- mods[0].modKind = EventMod.ModKind.SourceNameMatch;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setSourceNameMatch(sourceNamePattern)
+ .build();
return setEvent(event);
}
/**
- * Sets ClassUnload event request for given class name pattern.
+ * Sets ClassUnload event request for given class name pattern with suspend policy ALL.
*
* @param classRegexp
- * class pattern
+ * class name pattern
* @return ReplyPacket for setting request
*/
public ReplyPacket setClassUnload(String classRegexp) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.CLASS_UNLOAD;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- // EventMod[] mods = new EventMod[1];
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].classPattern = classRegexp;
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassMatchEvent(JDWPConstants.EventKind.CLASS_UNLOAD,
+ JDWPConstants.SuspendPolicy.ALL, classRegexp);
}
/**
- * Set ClassUnload event request for given class ID.
- *
+ * Set ClassUnload event request for given class ID with suspend policy ALL.
+ *
* @param referenceTypeID
* class referenceTypeID
* @return ReplyPacket for setting request
*/
public ReplyPacket setClassUnload(long referenceTypeID) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.CLASS_UNLOAD;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- // EventMod[] mods = new EventMod[1];
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].clazz = referenceTypeID;
- mods[0].modKind = EventMod.ModKind.ClassOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassOnlyEvent(JDWPConstants.EventKind.CLASS_UNLOAD,
+ JDWPConstants.SuspendPolicy.ALL, referenceTypeID);
}
/**
- * Sets ClassLoad event request for given class signature.
- *
+ * Sets ClassLoad event request for given class signature with suspend policy ALL.
+ *
* @param classSignature
* class signature
* @return ReplyPacket for setting request
@@ -1118,23 +1020,15 @@
}
/**
- * Set ClassLoad event request for given class ID.
- *
+ * Set ClassLoad event request for given class ID with suspend policy ALL.
+ *
* @param referenceTypeID
* class referenceTypeID
* @return ReplyPacket for setting request
*/
public ReplyPacket setClassLoad(long referenceTypeID) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.CLASS_LOAD;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].clazz = referenceTypeID;
- mods[0].modKind = EventMod.ModKind.ClassOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassOnlyEvent(JDWPConstants.EventKind.CLASS_LOAD,
+ JDWPConstants.SuspendPolicy.ALL, referenceTypeID);
}
/**
@@ -1145,29 +1039,20 @@
* @return ReplyPacket for setting request
*/
public ReplyPacket setMonitorContendedEnterForClassOnly(long referenceTypeID) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_CONTENDED_ENTER;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].clazz = referenceTypeID;
- mods[0].modKind = EventMod.ModKind.ClassOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassOnlyEvent(JDWPConstants.EventKind.MONITOR_CONTENDED_ENTER,
+ JDWPConstants.SuspendPolicy.ALL, referenceTypeID);
}
+ /**
+ * Set MonitorContendedEnter event request for given class's name pattern
+ *
+ * @param classRegexp
+ * class name pattern
+ * @return ReplyPacket for setting request
+ */
public ReplyPacket setMonitorContendedEnterForClassMatch(String classRegexp) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_CONTENDED_ENTER;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].classPattern = classRegexp;
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassMatchEvent(JDWPConstants.EventKind.MONITOR_CONTENDED_ENTER,
+ JDWPConstants.SuspendPolicy.ALL, classRegexp);
}
/**
@@ -1178,29 +1063,20 @@
* @return ReplyPacket for setting request
*/
public ReplyPacket setMonitorContendedEnteredForClassOnly(long referenceTypeID) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_CONTENDED_ENTERED;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].clazz = referenceTypeID;
- mods[0].modKind = EventMod.ModKind.ClassOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassOnlyEvent(JDWPConstants.EventKind.MONITOR_CONTENDED_ENTERED,
+ JDWPConstants.SuspendPolicy.ALL, referenceTypeID);
}
+ /**
+ * Set MonitorContendedEntered event request for given class's name pattern
+ *
+ * @param classRegexp
+ * class name pattern
+ * @return ReplyPacket for setting request
+ */
public ReplyPacket setMonitorContendedEnteredForClassMatch(String classRegexp) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_CONTENDED_ENTERED;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].classPattern = classRegexp;
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassMatchEvent(JDWPConstants.EventKind.MONITOR_CONTENDED_ENTERED,
+ JDWPConstants.SuspendPolicy.ALL, classRegexp);
}
/**
@@ -1211,16 +1087,8 @@
* @return ReplyPacket for setting request
*/
public ReplyPacket setMonitorWaitForClassOnly(long referenceTypeID) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_WAIT;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].clazz = referenceTypeID;
- mods[0].modKind = EventMod.ModKind.ClassOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassOnlyEvent(JDWPConstants.EventKind.MONITOR_WAIT,
+ JDWPConstants.SuspendPolicy.ALL, referenceTypeID);
}
/**
@@ -1233,16 +1101,8 @@
* @return ReplyPacket for setting request.
*/
public ReplyPacket setMonitorWaitForClassMatch(String classRegexp) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_WAIT;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].classPattern = classRegexp;
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassMatchEvent(JDWPConstants.EventKind.MONITOR_WAIT,
+ JDWPConstants.SuspendPolicy.ALL, classRegexp);
}
/**
@@ -1256,16 +1116,8 @@
* @return ReplyPacket for setting request.
*/
public ReplyPacket setMonitorWaitForClassExclude (String classRegexp) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_WAIT;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].classPattern = classRegexp;
- mods[0].modKind = EventMod.ModKind.ClassExclude;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassExcludeEvent(JDWPConstants.EventKind.MONITOR_WAIT,
+ JDWPConstants.SuspendPolicy.ALL, classRegexp);
}
/**
@@ -1276,16 +1128,8 @@
* @return ReplyPacket for setting request
*/
public ReplyPacket setMonitorWaitedForClassOnly(long referenceTypeID) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_WAITED;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].clazz = referenceTypeID;
- mods[0].modKind = EventMod.ModKind.ClassOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassOnlyEvent(JDWPConstants.EventKind.MONITOR_WAITED,
+ JDWPConstants.SuspendPolicy.ALL, referenceTypeID);
}
/**
@@ -1298,16 +1142,8 @@
* @return ReplyPacket for setting request.
*/
public ReplyPacket setMonitorWaitedForClassMatch(String classRegexp) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_WAITED;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].classPattern = classRegexp;
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassMatchEvent(JDWPConstants.EventKind.MONITOR_WAITED,
+ JDWPConstants.SuspendPolicy.ALL, classRegexp);
}
/**
@@ -1321,16 +1157,8 @@
* @return ReplyPacket for setting request.
*/
public ReplyPacket setMonitorWaitedForClassExclude (String classRegexp) {
- // Prepare corresponding event
- byte eventKind = JDWPConstants.EventKind.MONITOR_WAITED;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].classPattern = classRegexp;
- mods[0].modKind = EventMod.ModKind.ClassExclude;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
- return setEvent(event);
+ return setClassExcludeEvent(JDWPConstants.EventKind.MONITOR_WAITED,
+ JDWPConstants.SuspendPolicy.ALL, classRegexp);
}
/**
@@ -1352,79 +1180,79 @@
commandPacket.setNextValueAsByte(event.suspendPolicy);
// Set modifiers
- commandPacket.setNextValueAsInt(event.modifiers);
+ commandPacket.setNextValueAsInt(event.mods.size());
- for (int i = 0; i < event.modifiers; i++) {
+ for (EventMod eventModifier : event.mods) {
- commandPacket.setNextValueAsByte(event.mods[i].modKind);
+ commandPacket.setNextValueAsByte(eventModifier.modKind);
- switch (event.mods[i].modKind) {
- case EventMod.ModKind.Count: {
- // Case Count
- commandPacket.setNextValueAsInt(event.mods[i].count);
- break;
- }
- case EventMod.ModKind.Conditional: {
- // Case Conditional
- commandPacket.setNextValueAsInt(event.mods[i].exprID);
- break;
- }
- case EventMod.ModKind.ThreadOnly: {
- // Case ThreadOnly
- commandPacket.setNextValueAsThreadID(event.mods[i].thread);
- break;
- }
- case EventMod.ModKind.ClassOnly: {
- // Case ClassOnly
- commandPacket
- .setNextValueAsReferenceTypeID(event.mods[i].clazz);
- break;
- }
- case EventMod.ModKind.ClassMatch: {
- // Case ClassMatch
- commandPacket.setNextValueAsString(event.mods[i].classPattern);
- break;
- }
- case EventMod.ModKind.ClassExclude: {
- // Case ClassExclude
- commandPacket.setNextValueAsString(event.mods[i].classPattern);
- break;
- }
- case EventMod.ModKind.LocationOnly: {
- // Case LocationOnly
- commandPacket.setNextValueAsLocation(event.mods[i].loc);
- break;
- }
- case EventMod.ModKind.ExceptionOnly:
- // Case ExceptionOnly
- commandPacket
- .setNextValueAsReferenceTypeID(event.mods[i].exceptionOrNull);
- commandPacket.setNextValueAsBoolean(event.mods[i].caught);
- commandPacket.setNextValueAsBoolean(event.mods[i].uncaught);
- break;
- case EventMod.ModKind.FieldOnly: {
- // Case FieldOnly
- commandPacket
- .setNextValueAsReferenceTypeID(event.mods[i].declaring);
- commandPacket.setNextValueAsFieldID(event.mods[i].fieldID);
- break;
- }
- case EventMod.ModKind.Step: {
- // Case Step
- commandPacket.setNextValueAsThreadID(event.mods[i].thread);
- commandPacket.setNextValueAsInt(event.mods[i].size);
- commandPacket.setNextValueAsInt(event.mods[i].depth);
- break;
- }
- case EventMod.ModKind.InstanceOnly: {
- // Case InstanceOnly
- commandPacket.setNextValueAsObjectID(event.mods[i].instance);
- break;
- }
- case EventMod.ModKind.SourceNameMatch: {
- // Case SourceNameMatch
- commandPacket.setNextValueAsString(event.mods[i].sourceNamePattern);
- }
+ switch (eventModifier.modKind) {
+ case EventMod.ModKind.Count: {
+ // Case Count
+ commandPacket.setNextValueAsInt(eventModifier.count);
+ break;
+ }
+ case EventMod.ModKind.Conditional: {
+ // Case Conditional
+ commandPacket.setNextValueAsInt(eventModifier.exprID);
+ break;
+ }
+ case EventMod.ModKind.ThreadOnly: {
+ // Case ThreadOnly
+ commandPacket.setNextValueAsThreadID(eventModifier.thread);
+ break;
+ }
+ case EventMod.ModKind.ClassOnly: {
+ // Case ClassOnly
+ commandPacket
+ .setNextValueAsReferenceTypeID(eventModifier.clazz);
+ break;
+ }
+ case EventMod.ModKind.ClassMatch: {
+ // Case ClassMatch
+ commandPacket.setNextValueAsString(eventModifier.classPattern);
+ break;
+ }
+ case EventMod.ModKind.ClassExclude: {
+ // Case ClassExclude
+ commandPacket.setNextValueAsString(eventModifier.classPattern);
+ break;
+ }
+ case EventMod.ModKind.LocationOnly: {
+ // Case LocationOnly
+ commandPacket.setNextValueAsLocation(eventModifier.loc);
+ break;
+ }
+ case EventMod.ModKind.ExceptionOnly:
+ // Case ExceptionOnly
+ commandPacket
+ .setNextValueAsReferenceTypeID(eventModifier.exceptionOrNull);
+ commandPacket.setNextValueAsBoolean(eventModifier.caught);
+ commandPacket.setNextValueAsBoolean(eventModifier.uncaught);
+ break;
+ case EventMod.ModKind.FieldOnly: {
+ // Case FieldOnly
+ commandPacket
+ .setNextValueAsReferenceTypeID(eventModifier.declaring);
+ commandPacket.setNextValueAsFieldID(eventModifier.fieldID);
+ break;
+ }
+ case EventMod.ModKind.Step: {
+ // Case Step
+ commandPacket.setNextValueAsThreadID(eventModifier.thread);
+ commandPacket.setNextValueAsInt(eventModifier.size);
+ commandPacket.setNextValueAsInt(eventModifier.depth);
+ break;
+ }
+ case EventMod.ModKind.InstanceOnly: {
+ // Case InstanceOnly
+ commandPacket.setNextValueAsObjectID(eventModifier.instance);
+ break;
+ }
+ case EventMod.ModKind.SourceNameMatch: {
+ // Case SourceNameMatch
+ commandPacket.setNextValueAsString(eventModifier.sourceNamePattern);
+ }
}
}
@@ -1521,52 +1349,11 @@
*/
public ReplyPacket setException(long exceptionID, boolean caught,
boolean uncaught) {
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.EXCEPTION;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[1];
- mods[0] = new EventMod();
- mods[0].modKind = EventMod.ModKind.ExceptionOnly;
- mods[0].caught = caught;
- mods[0].uncaught = uncaught;
- mods[0].exceptionOrNull = exceptionID;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- return setEvent(event);
- }
-
- /**
- * Sets exception event request for given exception class signature.
- *
- * @param exceptionSignature
- * exception signature.
- * @param caught
- * is exception caught
- * @param uncaught
- * is exception uncaught
- * @param count
- * Limit the requested event to be reported at most once after a
- * given number of occurrences
- * @return ReplyPacket for corresponding command
- */
- public ReplyPacket setCountableException(String exceptionSignature,
- boolean caught, boolean uncaught, int count) {
- // Request referenceTypeID for exception
- long exceptionID = getClassID(exceptionSignature);
- byte eventKind = JDWPConstants.EventKind.EXCEPTION;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[2];
- mods[0] = new EventMod();
- mods[0].modKind = EventMod.ModKind.ExceptionOnly;
- mods[0].caught = caught;
- mods[0].uncaught = uncaught;
- mods[0].exceptionOrNull = exceptionID;
-
- mods[1] = new EventMod();
- mods[1].modKind = EventMod.ModKind.Count;
- mods[1].count = count;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setExceptionOnly(exceptionID, caught, uncaught)
+ .build();
return setEvent(event);
}
@@ -1579,53 +1366,13 @@
* @return ReplyPacket for corresponding command
*/
public ReplyPacket setMethodEntry(String classRegexp) {
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.METHOD_ENTRY;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = null;
- if (classRegexp == null) {
- mods = new EventMod[0];
- } else {
- mods = new EventMod[1];
- mods[0] = new EventMod();
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- mods[0].classPattern = classRegexp;
+ EventBuilder builder = Event.builder(eventKind, suspendPolicy);
+ if (classRegexp != null) {
+ builder = builder.setClassMatch(classRegexp);
}
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- return setEvent(event);
- }
-
- /**
- * Sets METHOD_ENTRY event request for specified class name pattern.
- *
- * @param classRegexp
- * class name pattern or null for no pattern
- * @param count
- * Limit the requested event to be reported at most once after a
- * given number of occurrences
- * @return ReplyPacket for corresponding command
- */
- public ReplyPacket setCountableMethodEntry(String classRegexp, int count) {
- byte eventKind = JDWPConstants.EventKind.METHOD_ENTRY;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = null;
- if (classRegexp == null) {
- mods = new EventMod[] { new EventMod() };
- mods[0].modKind = EventMod.ModKind.Count;
- mods[0].count = count;
- } else {
- mods = new EventMod[2];
- mods[0] = new EventMod();
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- mods[0].classPattern = classRegexp;
-
- mods[1] = new EventMod();
- mods[1].modKind = EventMod.ModKind.Count;
- mods[1].count = count;
- }
- Event event = new Event(eventKind, suspendPolicy, mods);
-
+ Event event = builder.build();
return setEvent(event);
}
@@ -1638,20 +1385,13 @@
* @return ReplyPacket for corresponding command
*/
public ReplyPacket setMethodExit(String classRegexp) {
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.METHOD_EXIT;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = null;
- if (classRegexp == null) {
- mods = new EventMod[0];
- } else {
- mods = new EventMod[1];
- mods[0] = new EventMod();
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- mods[0].classPattern = classRegexp;
+ EventBuilder builder = Event.builder(eventKind, suspendPolicy);
+ if (classRegexp != null) {
+ builder = builder.setClassMatch(classRegexp);
}
- Event event = new Event(eventKind, suspendPolicy, mods);
-
+ Event event = builder.build();
return setEvent(event);
}
@@ -1664,58 +1404,17 @@
* @return ReplyPacket for corresponding command
*/
public ReplyPacket setMethodExitWithReturnValue(String classRegexp) {
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.METHOD_EXIT_WITH_RETURN_VALUE;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = null;
- if (classRegexp == null) {
- mods = new EventMod[0];
- } else {
- mods = new EventMod[1];
- mods[0] = new EventMod();
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- mods[0].classPattern = classRegexp;
+ EventBuilder builder = Event.builder(eventKind, suspendPolicy);
+ if (classRegexp != null) {
+ builder = builder.setClassMatch(classRegexp);
}
- Event event = new Event(eventKind, suspendPolicy, mods);
-
+ Event event = builder.build();
return setEvent(event);
}
/**
- * Sets METHOD_EXIT event request for specified class name pattern.
- *
- * @param classRegexp
- * classRegexp class name pattern or null for no pattern
- * @param count
- * Limit the requested event to be reported at most once after a
- * given number of occurrences
- * @return ReplyPacket for corresponding command
- */
- public ReplyPacket setCountableMethodExit(String classRegexp, int count) {
- byte eventKind = JDWPConstants.EventKind.METHOD_EXIT;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = null;
- if (classRegexp == null) {
- mods = new EventMod[] { new EventMod() };
- mods[0].modKind = EventMod.ModKind.Count;
- mods[0].count = count;
- } else {
- mods = new EventMod[2];
- mods[0] = new EventMod();
- mods[0].modKind = EventMod.ModKind.ClassMatch;
- mods[0].classPattern = classRegexp;
-
- mods[1] = new EventMod();
- mods[1].modKind = EventMod.ModKind.Count;
- mods[1].count = count;
- }
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- return setEvent(event);
-
- }
-
- /**
* Sets field access event request for specified class signature and field
* name.
*
@@ -1726,34 +1425,20 @@
* @param fieldName
* field name
* @return ReplyPacket if breakpoint is set
- * @throws ReplyErrorCodeException
*/
public ReplyPacket setFieldAccess(String classSignature, byte classTypeTag,
- String fieldName) throws ReplyErrorCodeException {
- ReplyPacket request = null;
- long typeID = -1;
- long fieldID = -1;
-
+ String fieldName) {
// Request referenceTypeID for class
- typeID = getClassID(classSignature);
-
- // Request fields in class
- request = getFieldsInClass(typeID);
+ long typeID = getClassID(classSignature);
// Get fieldID from received packet
- fieldID = getFieldID(request, fieldName);
+ long fieldID = getFieldID(typeID, fieldName);
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.FIELD_ACCESS;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- // EventMod[] mods = new EventMod[1];
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].fieldID = fieldID;
- mods[0].declaring = typeID;
- mods[0].modKind = EventMod.ModKind.FieldOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set exception
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setFieldOnly(typeID, fieldID)
+ .build();
return setEvent(event);
}
@@ -1768,34 +1453,20 @@
* @param fieldName
* field name
* @return ReplyPacket for corresponding command
- * @throws ReplyErrorCodeException
*/
public ReplyPacket setFieldModification(String classSignature,
- byte classTypeTag, String fieldName) throws ReplyErrorCodeException {
- ReplyPacket request = null;
- long typeID = -1;
- long fieldID = -1;
-
+ byte classTypeTag, String fieldName) {
// Request referenceTypeID for class
- typeID = getClassID(classSignature);
-
- // Request fields in class
- request = getFieldsInClass(typeID);
+ long typeID = getClassID(classSignature);
// Get fieldID from received packet
- fieldID = getFieldID(request, fieldName);
+ long fieldID = getFieldID(typeID, fieldName);
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.FIELD_MODIFICATION;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- // EventMod[] mods = new EventMod[1];
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].fieldID = fieldID;
- mods[0].declaring = typeID;
- mods[0].modKind = EventMod.ModKind.FieldOnly;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setFieldOnly(typeID, fieldID)
+ .build();
return setEvent(event);
}
@@ -1811,17 +1482,11 @@
* @return ReplyPacket for corresponding command
*/
public ReplyPacket setStep(long threadID, int stepSize, int stepDepth) {
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.SINGLE_STEP;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[] { new EventMod() };
- mods[0].thread = threadID;
- mods[0].modKind = EventMod.ModKind.Step;
- mods[0].size = stepSize;
- mods[0].depth = stepDepth;
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setStep(threadID, stepSize, stepDepth)
+ .build();
return setEvent(event);
}
@@ -1839,27 +1504,13 @@
*/
public ReplyPacket setStep(String[] classRegexp, long threadID,
int stepSize, int stepDepth) {
- // Prepare corresponding event
byte eventKind = JDWPConstants.EventKind.SINGLE_STEP;
byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- int modsSize = classRegexp.length + 1;
- EventMod[] mods = new EventMod[modsSize];
- for (int i = 0; i < classRegexp.length; i++) {
- mods[i] = new EventMod();
- mods[i].classPattern = classRegexp[i];
- mods[i].modKind = EventMod.ModKind.ClassExclude;
+ EventBuilder builder = Event.builder(eventKind, suspendPolicy);
+ for (String pattern : classRegexp) {
+ builder.setClassExclude(pattern);
}
-
- int index = modsSize - 1;
- mods[index] = new EventMod();
- mods[index].modKind = EventMod.ModKind.Step;
- mods[index].thread = threadID;
- mods[index].size = stepSize;
- mods[index].depth = stepDepth;
-
- Event event = new Event(eventKind, suspendPolicy, mods);
-
- // Set event
+ Event event = builder.setStep(threadID, stepSize, stepDepth).build();
return setEvent(event);
}
@@ -1868,28 +1519,42 @@
*
* @return ReplyPacket for corresponding command
*/
- public ReplyPacket setThreadStart() {
- // Prepare corresponding event
+ public ReplyPacket setThreadStart(byte suspendPolicy) {
byte eventKind = JDWPConstants.EventKind.THREAD_START;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[0];
- Event event = new Event(eventKind, suspendPolicy, mods);
-
+ Event event = Event.builder(eventKind, suspendPolicy).build();
return setEvent(event);
}
/**
* Sets THREAD_END event request.
- *
+ *
+ * @param suspendPolicy the suspend policy
* @return ReplyPacket for corresponding command
*/
- public ReplyPacket setThreadEnd() {
- // Prepare corresponding event
+ public ReplyPacket setThreadEnd(byte suspendPolicy) {
byte eventKind = JDWPConstants.EventKind.THREAD_END;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.ALL;
- EventMod[] mods = new EventMod[0];
- Event event = new Event(eventKind, suspendPolicy, mods);
+ Event event = Event.builder(eventKind, suspendPolicy).build();
+ return setEvent(event);
+ }
+ private ReplyPacket setClassOnlyEvent(byte eventKind, byte suspendPolicy, long classId) {
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setClassOnly(classId)
+ .build();
+ return setEvent(event);
+ }
+
+ private ReplyPacket setClassMatchEvent(byte eventKind, byte suspendPolicy, String pattern) {
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setClassMatch(pattern)
+ .build();
+ return setEvent(event);
+ }
+
+ private ReplyPacket setClassExcludeEvent(byte eventKind, byte suspendPolicy, String pattern) {
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setClassExclude(pattern)
+ .build();
return setEvent(event);
}
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/EventModifiers/JDWPEventModifierTestCase.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/EventModifiers/JDWPEventModifierTestCase.java
index ae66ba1..7876c62 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/EventModifiers/JDWPEventModifierTestCase.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/EventModifiers/JDWPEventModifierTestCase.java
@@ -60,10 +60,8 @@
long typeID = debuggeeWrapper.vmMirror.getTypeID(breakpoint.className, typeTag);
long methodID = getMethodID(typeID, breakpoint.methodName);
byte eventKind = JDWPConstants.EventKind.BREAKPOINT;
- EventBuilder builder = new EventBuilder(eventKind, TEST_SUSPEND_POLICY);
- builder.setLocationOnly(new Location(typeTag, typeID, methodID,
- breakpoint.index));
- return builder;
+ return Event.builder(eventKind, TEST_SUSPEND_POLICY)
+ .setLocationOnly(new Location(typeTag, typeID, methodID, breakpoint.index));
}
/**
@@ -78,13 +76,12 @@
protected EventBuilder createExceptionEventBuilder(
String exceptionClassSignature, boolean caught, boolean uncaught) {
byte eventKind = JDWPConstants.EventKind.EXCEPTION;
- EventBuilder builder = new EventBuilder(eventKind, TEST_SUSPEND_POLICY);
long exceptionClassID = debuggeeWrapper.vmMirror.getClassID(
exceptionClassSignature);
assertTrue("Failed to find type ID " + exceptionClassSignature,
exceptionClassID != 1);
- builder.setExceptionOnly(exceptionClassID, caught, uncaught);
- return builder;
+ return Event.builder(eventKind, TEST_SUSPEND_POLICY).setExceptionOnly(exceptionClassID,
+ caught, uncaught);
}
/**
@@ -96,9 +93,8 @@
* @return a new {@link EventBuilder}
*/
protected EventBuilder createMethodEntryEventBuilder(String className) {
- EventBuilder builder = new EventBuilder(
- JDWPConstants.EventKind.METHOD_ENTRY, TEST_SUSPEND_POLICY);
- return builder.setClassMatch(className);
+ return Event.builder(JDWPConstants.EventKind.METHOD_ENTRY, TEST_SUSPEND_POLICY)
+ .setClassMatch(className);
}
/**
@@ -110,9 +106,8 @@
* @return a new {@link EventBuilder}
*/
protected EventBuilder createMethodExitEventBuilder(String className) {
- EventBuilder builder = new EventBuilder(
- JDWPConstants.EventKind.METHOD_EXIT, TEST_SUSPEND_POLICY);
- return builder.setClassMatch(className);
+ return Event.builder(JDWPConstants.EventKind.METHOD_EXIT, TEST_SUSPEND_POLICY)
+ .setClassMatch(className);
}
/**
@@ -124,10 +119,9 @@
* @return a new {@link EventBuilder}
*/
protected EventBuilder createMethodExitWithReturnValueEventBuilder(String className) {
- EventBuilder builder = new EventBuilder(
- JDWPConstants.EventKind.METHOD_EXIT_WITH_RETURN_VALUE,
- TEST_SUSPEND_POLICY);
- return builder.setClassMatch(className);
+ return Event
+ .builder(JDWPConstants.EventKind.METHOD_EXIT_WITH_RETURN_VALUE, TEST_SUSPEND_POLICY)
+ .setClassMatch(className);
}
/**
@@ -136,8 +130,7 @@
* @return a new {@link EventBuilder}
*/
protected EventBuilder createThreadStartBuilder() {
- return new EventBuilder(JDWPConstants.EventKind.THREAD_START,
- TEST_SUSPEND_POLICY);
+ return Event.builder(JDWPConstants.EventKind.THREAD_START, TEST_SUSPEND_POLICY);
}
/**
@@ -146,8 +139,7 @@
* @return a new {@link EventBuilder}
*/
protected EventBuilder createThreadEndBuilder() {
- return new EventBuilder(JDWPConstants.EventKind.THREAD_END,
- TEST_SUSPEND_POLICY);
+ return Event.builder(JDWPConstants.EventKind.THREAD_END, TEST_SUSPEND_POLICY);
}
/**
@@ -188,14 +180,12 @@
} else {
eventKind = JDWPConstants.EventKind.FIELD_ACCESS;
}
- EventBuilder builder = new EventBuilder(eventKind, TEST_SUSPEND_POLICY);
long typeID = debuggeeWrapper.vmMirror.getTypeID(typeSignature, typeTag);
assertTrue("Failed to find type ID " + typeSignature, typeID != 1);
long fieldID = debuggeeWrapper.vmMirror.getFieldID(typeID, fieldName);
assertTrue("Failed to find field ID " + typeSignature + "." + fieldName,
fieldID != 1);
- builder.setFieldOnly(typeID, fieldID);
- return builder;
+ return Event.builder(eventKind, TEST_SUSPEND_POLICY).setFieldOnly(typeID, fieldID);
}
/**
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepare002Test.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepare002Test.java
index 37a2c5a..4c1498e 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepare002Test.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ClassPrepare002Test.java
@@ -20,7 +20,7 @@
import java.io.IOException;
import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
-import org.apache.harmony.jpda.tests.framework.jdwp.EventBuilder;
+import org.apache.harmony.jpda.tests.framework.jdwp.Event;
import org.apache.harmony.jpda.tests.framework.jdwp.EventPacket;
import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
@@ -58,10 +58,12 @@
// Request CLASS_PREPARE event. The event will be caused by the debugger thread when
// handling the ReferenceType.GetValues command we're going to send just after.
- EventBuilder eventBuilder = new EventBuilder(JDWPConstants.EventKind.CLASS_PREPARE,
- JDWPConstants.SuspendPolicy.EVENT_THREAD);
- eventBuilder.setClassMatch(classPrepareClassName);
- ReplyPacket eventReply = debuggeeWrapper.vmMirror.setEvent(eventBuilder.build());
+ final byte eventKind = JDWPConstants.EventKind.CLASS_PREPARE;
+ final byte suspendPolicy = JDWPConstants.SuspendPolicy.EVENT_THREAD;
+ Event event = Event.builder(eventKind, suspendPolicy)
+ .setClassMatch(classPrepareClassName)
+ .build();
+ ReplyPacket eventReply = debuggeeWrapper.vmMirror.setEvent(event);
checkReplyPacket(eventReply, "Failed to set CLASS_PREPARE event");
int classPrepareRequestId = eventReply.getNextValueAsInt();
assertAllDataRead(eventReply);
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/EventLocationEventTestCase.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/EventLocationEventTestCase.java
index a363121..bd65434 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/EventLocationEventTestCase.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/EventLocationEventTestCase.java
@@ -109,8 +109,7 @@
for (long idx = startIndex; idx <= endIndex; ++idx) {
Location location = new Location(JDWPConstants.TypeTag.CLASS,
typeId, methodId, idx);
- EventBuilder builder = new EventBuilder(eventKind,
- JDWPConstants.SuspendPolicy.ALL);
+ EventBuilder builder = Event.builder(eventKind, JDWPConstants.SuspendPolicy.ALL);
createEventBuilder(builder);
setEvent(builder, location);
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java
index 250e2e1..8029904 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ThreadEndTest.java
@@ -26,8 +26,6 @@
package org.apache.harmony.jpda.tests.jdwp.Events;
import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
-import org.apache.harmony.jpda.tests.framework.jdwp.Event;
-import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
@@ -50,13 +48,8 @@
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
logWriter.println("=> set ThreadEndEvent...");
- ReplyPacket reply;
- byte eventKind = JDWPConstants.EventKind.THREAD_END;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.NONE;
- EventMod[] mods = new EventMod[0];
- Event eventToSet = new Event(eventKind, suspendPolicy, mods);
-
- reply = debuggeeWrapper.vmMirror.setEvent(eventToSet);
+ ReplyPacket reply =
+ debuggeeWrapper.vmMirror.setThreadEnd(JDWPConstants.SuspendPolicy.NONE);
checkReplyPacket(reply, "Set THREAD_END event");
logWriter.println("=> set ThreadEndEvent - DONE");
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java
index 58c696f..dbe4221 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/Events/ThreadStartTest.java
@@ -26,8 +26,6 @@
package org.apache.harmony.jpda.tests.jdwp.Events;
import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
-import org.apache.harmony.jpda.tests.framework.jdwp.Event;
-import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
@@ -52,13 +50,8 @@
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
logWriter.println("=> set ThreadStartEvent...");
- ReplyPacket reply;
- byte eventKind = JDWPConstants.EventKind.THREAD_START;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.NONE;
- EventMod[] mods = new EventMod[0];
- Event eventToSet = new Event(eventKind, suspendPolicy, mods);
-
- reply = debuggeeWrapper.vmMirror.setEvent(eventToSet);
+ ReplyPacket reply =
+ debuggeeWrapper.vmMirror.setThreadStart(JDWPConstants.SuspendPolicy.NONE);
checkReplyPacket(reply, "Set THREAD_START event");
logWriter.println("=> set ThreadStartEvent - DONE");
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/MultiSession/ThreadEndTest.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/MultiSession/ThreadEndTest.java
index 9717bb6..9f50789 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/MultiSession/ThreadEndTest.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/MultiSession/ThreadEndTest.java
@@ -28,8 +28,6 @@
import org.apache.harmony.jpda.tests.framework.TestOptions;
import org.apache.harmony.jpda.tests.framework.TestErrorException;
import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
-import org.apache.harmony.jpda.tests.framework.jdwp.Event;
-import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
@@ -53,13 +51,8 @@
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
logWriter.println("=> set ThreadEndEvent...");
- ReplyPacket reply;
- byte eventKind = JDWPConstants.EventKind.THREAD_END;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.NONE;
- EventMod[] mods = new EventMod[0];
- Event eventToSet = new Event(eventKind, suspendPolicy, mods);
-
- reply = debuggeeWrapper.vmMirror.setEvent(eventToSet);
+ ReplyPacket reply =
+ debuggeeWrapper.vmMirror.setThreadEnd(JDWPConstants.SuspendPolicy.NONE);
checkReplyPacket(reply, "Set THREAD_END event");
logWriter.println("=> set ThreadEndEvent - DONE");
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/MultiSession/ThreadStartTest.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/MultiSession/ThreadStartTest.java
index 600e5a6..6590071 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/MultiSession/ThreadStartTest.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/MultiSession/ThreadStartTest.java
@@ -28,8 +28,6 @@
import org.apache.harmony.jpda.tests.framework.TestOptions;
import org.apache.harmony.jpda.tests.framework.TestErrorException;
import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
-import org.apache.harmony.jpda.tests.framework.jdwp.Event;
-import org.apache.harmony.jpda.tests.framework.jdwp.EventMod;
import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
import org.apache.harmony.jpda.tests.framework.jdwp.ParsedEvent;
import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
@@ -53,14 +51,8 @@
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
logWriter.println("=> set ThreadStartEvent...");
- ReplyPacket reply;
- // reply = debuggeeWrapper.vmMirror.setThreadStart();
- byte eventKind = JDWPConstants.EventKind.THREAD_START;
- byte suspendPolicy = JDWPConstants.SuspendPolicy.NONE;
- EventMod[] mods = new EventMod[0];
- Event eventToSet = new Event(eventKind, suspendPolicy, mods);
-
- reply = debuggeeWrapper.vmMirror.setEvent(eventToSet);
+ ReplyPacket reply =
+ debuggeeWrapper.vmMirror.setThreadStart(JDWPConstants.SuspendPolicy.NONE);
checkReplyPacket(reply, "Set THREAD_START event");
logWriter.println("=> set ThreadStartEvent - DONE");
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsTest.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsTest.java
index bdf3c26..20c39de 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsTest.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/HoldEventsTest.java
@@ -59,7 +59,7 @@
public void testHoldEvents001() {
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
- debuggeeWrapper.vmMirror.setThreadStart();
+ debuggeeWrapper.vmMirror.setThreadStart(JDWPConstants.SuspendPolicy.ALL);
//send HoldEvents command
logWriter.println("send HoldEvents");
diff --git a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsTest.java b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsTest.java
index 5c4bc4f..8a75374 100644
--- a/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsTest.java
+++ b/jdwp/src/test/java/org/apache/harmony/jpda/tests/jdwp/VirtualMachine/ReleaseEventsTest.java
@@ -69,7 +69,7 @@
public void testReleaseEvents001() {
synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
- debuggeeWrapper.vmMirror.setThreadStart();
+ debuggeeWrapper.vmMirror.setThreadStart(JDWPConstants.SuspendPolicy.ALL);
//send HoldEvents command
logWriter.println("send HoldEvents");