test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java
changeset 51583 ad2224d4f346
parent 50018 3ba0d8631f24
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java	Wed Aug 29 19:14:08 2018 -0700
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java	Tue Aug 28 08:06:59 2018 -0400
@@ -48,9 +48,9 @@
  * To check up on the method, a debugger,                       <BR>
  * upon getting new set for the EventSet,                       <BR>
  * suspends VM with the method VirtualMachine.suspend(),        <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
  * invokes the method EventSet.resume(), and                    <BR>
- * gets another List of geduggee's threads.                     <BR>
+ * gets another List of debuggee's threads.                     <BR>
  * The debugger then compares values of                         <BR>
  * each thread's suspendCount from first and second Lists.      <BR>
  * <BR>
@@ -87,12 +87,12 @@
 
 public class resume002 {
 
-    //----------------------------------------------------- templete section
+    //----------------------------------------------------- template section
     static final int PASSED = 0;
     static final int FAILED = 2;
     static final int PASS_BASE = 95;
 
-    //----------------------------------------------------- templete parameters
+    //----------------------------------------------------- template parameters
     static final String
     sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume002 ",
     sHeader2 = "--> debugger: ",
@@ -503,6 +503,7 @@
 
             log2("......--> vm.resume()");
             vm.resume();
+            informDebuggeeTestCase(i);
             //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         }
         log1("    TESTING ENDS");
@@ -642,5 +643,22 @@
             throw new JDITestRuntimeException("** FAILURE to set up AccessWatchpointRequest **");
         }
     }
-
+    /**
+     * Inform debuggee which thread test the debugger has completed.
+     * Used for synchronization, so the debuggee does not move too quickly.
+     * @param testCase index of just completed test
+     */
+    void informDebuggeeTestCase(int testCase) {
+        try {
+            ((ClassType)debuggeeClass)
+                .setValue(debuggeeClass.fieldByName("testCase"),
+                          vm.mirrorOf(testCase));
+        } catch (InvalidTypeException ite) {
+            throw new Failure("** FAILURE setting testCase  **");
+        } catch (ClassNotLoadedException cnle) {
+            throw new Failure("** FAILURE notifying debuggee  **");
+        } catch (VMDisconnectedException e) {
+            throw new Failure("** FAILURE debuggee connection **");
+        }
+    }
 }