8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg
authordtitov
Thu, 28 Feb 2019 13:12:26 -0800
changeset 53960 6c3fd94de35a
parent 53959 1542e63eb537
child 53961 e5b461681b88
8207367: 10 vmTestbase/nsk/jdi tests timed out when running with jtreg Reviewed-by: sspitsyn, cjplummer
test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassExclusionFilter/exclfilter001.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassFilter/filter001.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/_itself_/event001.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004a.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/suspend/suspend001.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java
test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/suspend/suspend001.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassExclusionFilter/exclfilter001.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassExclusionFilter/exclfilter001.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,15 @@
 
 package nsk.jdi.ClassUnloadRequest.addClassExclusionFilter;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jdi.*;
 
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
 import com.sun.jdi.request.*;
+
 import java.io.*;
-import java.util.*;
 
 /**
  * Debugger requests <code>ClassUnloadEvent</code> and sets class filter by calling
@@ -64,7 +65,7 @@
     private static int exitStatus;
     private static Log log;
     private static Debugee debugee;
-    private static int eventWaitTime;
+    private static long waitTime;
 
     String[] patterns = {
                     prefix + "Sub*",
@@ -88,7 +89,7 @@
         exclfilter001 tstObj = new exclfilter001();
 
         ArgumentHandler argHandler = new ArgumentHandler(argv);
-        eventWaitTime = argHandler.getWaitTime() * 60000;
+        waitTime = argHandler.getWaitTime();
         log = new Log(out, argHandler);
 
         debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
@@ -121,7 +122,7 @@
             debugee.sendSignal(SGNL_UNLOAD);
             debugee.receiveExpectedSignal(SGNL_READY);
 
-            receiveEvents(eventWaitTime, patterns[i]);
+            receiveEvents(patterns[i]);
 
             display("");
             debugee.getEventRequestManager().deleteEventRequest(request);
@@ -146,19 +147,20 @@
         return request;
     }
 
-    private void receiveEvents(int waitTime, String pattern) {
+    private void receiveEvents(String pattern) {
         EventSet eventSet = null;
         Event event;
-        int totalTime = waitTime;
+        long totalWaitTime = Utils.adjustTimeout(waitTime * 10000);
+        long waitTimeout = Utils.adjustTimeout(waitTime * 1000);
         long begin, delta;
         int count = 0;
         boolean exit = false;
 
         try {
             begin = System.currentTimeMillis();
-            eventSet = debugee.VM().eventQueue().remove(totalTime);
+            eventSet = debugee.VM().eventQueue().remove(waitTimeout);
             delta = System.currentTimeMillis() - begin;
-            totalTime -= delta;
+            totalWaitTime -= delta;
             while (eventSet != null) {
                 EventIterator eventIterator = eventSet.eventIterator();
                 while (eventIterator.hasNext()) {
@@ -174,14 +176,14 @@
                         throw new Failure("Unexpected VMDisconnectEvent received");
                     }
                 }
-                if (totalTime <= 0 || exit) {
+                if (totalWaitTime <= 0 || exit) {
                     break;
                 }
                 debugee.resume();
-                    begin = System.currentTimeMillis();
-                eventSet = debugee.VM().eventQueue().remove(totalTime);
+                begin = System.currentTimeMillis();
+                eventSet = debugee.VM().eventQueue().remove(waitTimeout);
                 delta = System.currentTimeMillis() - begin;
-                totalTime -= delta;
+                totalWaitTime -= delta;
             }
         } catch(InterruptedException e) {
             throw new Failure(e);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassFilter/filter001.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassUnloadRequest/addClassFilter/filter001.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 package nsk.jdi.ClassUnloadRequest.addClassFilter;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jdi.*;
 
@@ -63,7 +64,7 @@
     private static int exitStatus;
     private static Log log;
     private static Debugee debugee;
-    private static int eventWaitTime;
+    private static long waitTime;
 
     String[] patterns = {
                     prefix + "Sub*",
@@ -87,7 +88,8 @@
         filter001 tstObj = new filter001();
 
         ArgumentHandler argHandler = new ArgumentHandler(argv);
-        eventWaitTime = argHandler.getWaitTime() * 60000;
+        waitTime = argHandler.getWaitTime();
+
         log = new Log(out, argHandler);
 
         debugee = Debugee.prepareDebugee(argHandler, log, debugeeName);
@@ -120,7 +122,7 @@
             debugee.sendSignal(SGNL_UNLOAD);
             debugee.receiveExpectedSignal(SGNL_READY);
 
-            receiveEvents(eventWaitTime, patterns[i]);
+            receiveEvents(patterns[i]);
 
             display("");
             debugee.getEventRequestManager().deleteEventRequest(request);
@@ -145,19 +147,20 @@
         return request;
     }
 
-    private void receiveEvents(int waitTime, String pattern) {
+    private void receiveEvents(String pattern) {
         EventSet eventSet = null;
         Event event;
-        int totalTime = waitTime;
+        long totalWaitTime = Utils.adjustTimeout(waitTime * 10000);
+        long waitTimeout = Utils.adjustTimeout(waitTime * 1000);
         long begin, delta;
         int count = 0;
         boolean exit = false;
 
         try {
             begin = System.currentTimeMillis();
-            eventSet = debugee.VM().eventQueue().remove(totalTime);
+            eventSet = debugee.VM().eventQueue().remove(waitTimeout);
             delta = System.currentTimeMillis() - begin;
-            totalTime -= delta;
+            totalWaitTime -= delta;
             while (eventSet != null) {
                 EventIterator eventIterator = eventSet.eventIterator();
                 while (eventIterator.hasNext()) {
@@ -173,14 +176,14 @@
                         throw new Failure("Unexpected VMDisconnectEvent received");
                     }
                 }
-                if (totalTime <= 0 || exit) {
+                if (totalWaitTime <= 0 || exit) {
                     break;
                 }
                 debugee.resume();
-                    begin = System.currentTimeMillis();
-                eventSet = debugee.VM().eventQueue().remove(totalTime);
+                begin = System.currentTimeMillis();
+                eventSet = debugee.VM().eventQueue().remove(waitTimeout);
                 delta = System.currentTimeMillis() - begin;
-                totalTime -= delta;
+                totalWaitTime -= delta;
             }
         } catch(InterruptedException e) {
             throw new Failure(e);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/_itself_/event001.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/_itself_/event001.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 import java.util.List;
 import java.io.*;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -234,7 +235,7 @@
 
 // wait for a requested event
         try {
-            gotEvent.wait(argHandler.getWaitTime()*60000);
+            gotEvent.wait(Utils.adjustTimeout(argHandler.getWaitTime()*1000));
         } catch (InterruptedException e) {
             log.complain("TEST FAILURE: waiting for a requested AccessWatchpointEvent #"
                 + i + ": caught " + e);
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 package nsk.jdi.EventQueue.remove;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -67,7 +68,7 @@
  * <BR>
  * The check includes two steps.                                        <BR>
  * In first one, second thread waits for any incoming event from the    <BR>
- * debugger which is sleeping for "WAITTIME*90 seconds"; hence, <BR>
+ * debugger which is sleeping for some time; hence,                     <BR>
  * no events are expected to be received at the debugger end.           <BR>
  * In second, second thread is interrupted, and the debugger waits for  <BR>
  * a breakpoint event after the debuggee finishes sleeping.             <BR>
@@ -130,7 +131,7 @@
     static Debugee          debuggee;
     static ArgumentHandler  argsHandler;
 
-    static int waitTime;
+    static long waitTime;
 
     static VirtualMachine      vm            = null;
     static EventRequestManager eventRManager = null;
@@ -140,6 +141,8 @@
 
     static ReferenceType       debuggeeClass = null;
 
+    static Value trueValue;
+
     static int  testExitCode = PASSED;
 
     class JDITestRuntimeException extends RuntimeException {
@@ -156,7 +159,7 @@
         logHandler      = new Log(out, argsHandler);
         Binder binder   = new Binder(argsHandler, logHandler);
 
-        waitTime        = argsHandler.getWaitTime() * 60000;
+        waitTime        = Utils.adjustTimeout(argsHandler.getWaitTime() * 1000);
 
         try {
             log2("launching a debuggee :");
@@ -285,6 +288,8 @@
         if (!debuggeeClass.name().equals(debuggeeName))
            throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **");
 
+        trueValue = debuggeeClass.getValue(debuggeeClass.fieldByName("BOOLEAN_TRUE_VALUE"));
+
         log2("      received: ClassPrepareEvent for debuggeeClass");
 
         String bPointMethod = "methodForCommunication";
@@ -356,11 +361,11 @@
                 thread2.interrupt();
 
                 for (int i2 = 0; i2 < waitTime; ) {
-                    waitObj.wait(10000);
+                    waitObj.wait(1000);
                     if (!thread2.isAlive()) {
                         break;
                     }
-                    i2 += 10000;
+                    i2 += 1000;
                 }
                 if (thread2.isAlive()) {
                     log3("ERROR: thread2 is still alive");
@@ -508,9 +513,17 @@
                 log2("-----t2:  eventSet = eventQueue.remove(); expects: InterruptedException");
                 eventSet = eventQueue.remove();
                 throw new JDITestRuntimeException("** return from eventQueue.remove(); **");
-            } catch ( InterruptedException e1) {
+            } catch (InterruptedException e1) {
                 log2("-----t2:            InterruptedException");
-            } catch ( Exception e ) {
+                // Signal to debuggee to stop sleeping
+                try {
+                    ((ClassType) debuggeeClass).setValue(debuggeeClass.fieldByName("stopSleeping"),
+                            trueValue);
+                } catch (InvalidTypeException | ClassNotLoadedException e) {
+                    log3("ERROR: -----t2: Exception : " + e);
+                    testExitCode = FAILED;
+                }
+            } catch (Exception e) {
                 log3("ERROR: -----t2: Exception : " + e);
                 testExitCode = FAILED;
             }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004a.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 package nsk.jdi.EventQueue.remove;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -63,6 +64,12 @@
 
     static int lineForComm = 2;
 
+    // Used for communication between debugger and debuggee
+    static volatile boolean stopSleeping = false;
+
+    // Used by debugger to set stopSleeping flag to true
+    static  final boolean BOOLEAN_TRUE_VALUE = true;
+
     private static void methodForCommunication() {
         int i1 = instruction;
         int i2 = i1;
@@ -97,10 +104,12 @@
                                 log1("before: methodForCommunication();");
                                 methodForCommunication();
                                 log1("before: Thread.sleep");
-                                try {
-                                    Thread.sleep(argHandler.getWaitTime()*90000);
-                                } catch (InterruptedException e) {
-                                }
+                                Utils.waitForCondition(
+                                        () -> {
+                                            return stopSleeping;
+                                        },
+                                        Utils.adjustTimeout(argHandler.getWaitTime() * 10000),
+                                        100);
                                 log1("after: Thread.sleep");
                                 break ;
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 package nsk.jdi.EventQueue.remove_l;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -30,7 +31,6 @@
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
 import com.sun.jdi.request.*;
-
 import java.util.*;
 import java.io.*;
 
@@ -63,8 +63,8 @@
  * to be suspended and to inform the debugger with the event.           <BR>
  * The case for testing consists of of two steps.                       <BR>
  * In the first one the first assertion is checked up on as follows:    <BR>
- * the debugger sleeps for "WAITTIME * 90 sec";                         <BR>
- * hence, no event is expected in the debugger within WAITTINE, and     <BR>
+ * the debugger sleeps for some time;                                   <BR>
+ * hence, no event is expected in the debugger within WAITTIME, and     <BR>
  * debugger's method breakpointForCommunication() should get null.      <BR>
  * After WAITTIME, the debugger just expects to get normal breakpoint event.<BR>
  */
@@ -126,7 +126,7 @@
     static Debugee          debuggee;
     static ArgumentHandler  argsHandler;
 
-    static int waitTime;
+    static long waitTime;
 
     static VirtualMachine      vm            = null;
     static EventRequestManager eventRManager = null;
@@ -136,6 +136,8 @@
 
     static ReferenceType       debuggeeClass = null;
 
+    static Value trueValue;
+
     static int  testExitCode = PASSED;
 
     class JDITestRuntimeException extends RuntimeException {
@@ -152,7 +154,7 @@
         logHandler      = new Log(out, argsHandler);
         Binder binder   = new Binder(argsHandler, logHandler);
 
-        waitTime        = argsHandler.getWaitTime() * 60000;
+        waitTime        = Utils.adjustTimeout(argsHandler.getWaitTime() * 1000);
 
         try {
             log2("launching a debuggee :");
@@ -281,6 +283,8 @@
         if (!debuggeeClass.name().equals(debuggeeName))
            throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **");
 
+        trueValue = debuggeeClass.getValue(debuggeeClass.fieldByName("BOOLEAN_TRUE_VALUE"));
+
         log2("      received: ClassPrepareEvent for debuggeeClass");
 
         String bPointMethod = "methodForCommunication";
@@ -326,6 +330,11 @@
                     testExitCode = FAILED;
                     throw new JDITestRuntimeException("** unexpected Exception **");
                 }
+
+                // Signal to debuggee to stop sleeping
+                ((ClassType) debuggeeClass).setValue(debuggeeClass.fieldByName("stopSleeping"),
+                        trueValue);
+
             }
             //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004a.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004a.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 package nsk.jdi.EventQueue.remove_l;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -63,6 +64,12 @@
 
     static int lineForComm = 2;
 
+    // Used for communication between debugger and debuggee
+    static volatile boolean stopSleeping = false;
+
+    // Used by debugger to set stopSleeping flag to true
+    static  final boolean BOOLEAN_TRUE_VALUE = true;
+
     private static void methodForCommunication() {
         int i1 = instruction;
         int i2 = i1;
@@ -97,10 +104,12 @@
                                 log1("before: methodForCommunication();");
                                 methodForCommunication();
                                 log1("before: Thread.sleep");
-                                try {
-                                    Thread.sleep(argHandler.getWaitTime()*90000);
-                                } catch (InterruptedException e) {
-                                }
+                                Utils.waitForCondition(
+                                        () -> {
+                                            return stopSleeping;
+                                        },
+                                        Utils.adjustTimeout(argHandler.getWaitTime() * 10000),
+                                        100);
                                 log1("after: Thread.sleep");
                                 break ;
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/suspend/suspend001.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/suspend/suspend001.java	Thu Feb 28 13:12:26 2019 -0800
@@ -23,6 +23,7 @@
 
 package nsk.jdi.ThreadReference.suspend;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -429,7 +430,8 @@
      * It removes events from EventQueue until gets first BreakpointEvent.
      * To get next EventSet value, it uses the method
      *    EventQueue.remove(int timeout)
-     * The timeout argument passed to the method, is "waitTime*60000".
+     * The timeout argument passed to the method, is "waitTime*1000" adjusted to
+     * test.timeout.factor system property.
      * Note: the value of waitTime is set up with
      *       the method ArgumentHandler.getWaitTime() at the beginning of the test.
      *
@@ -451,7 +453,7 @@
 
                 log2("       new:  eventSet = eventQueue.remove();");
                 try {
-                    eventSet = eventQueue.remove (waitTime*60000);
+                    eventSet = eventQueue.remove(Utils.adjustTimeout(waitTime*1000));
                     if (eventSet == null) {
                         log2("::::::  timeout when waiting for a BreakpintEvent");
 //                        log3("ERROR:  timeout for waiting for a BreakpintEvent");
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002.java	Thu Feb 28 13:12:26 2019 -0800
@@ -23,6 +23,7 @@
 
 package nsk.jdi.VirtualMachine.dispose;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -272,29 +273,29 @@
                 if (expresult != returnCode0)
                     break label1;
 
-                log2("      Thread.sleep(waitTime*60000);");
-                try {
-                    Thread.sleep(waitTime*60000);
-                } catch ( InterruptedException e ) {
-                    log3("ERROR: InterruptedException");
-                    expresult = returnCode1;
-                    break label1;
-                }
+                log2("      Waiting for thread2 is not alive");
 
-                log2("......sending to the debuggee: 'check_alive'");
-                log2("       expected reply: 'not_alive'");
-                pipe.println("check_alive");
-                line = pipe.readln();
-                if (line.equals("alive")) {
-                    log3("ERROR: thread2 is alive");
-                    expresult = returnCode1;
-                } else if (line.equals("not_alive")) {
-                    log2("     thread2 is not alive");
-                } else {
-                    log3("ERROR: unexpected reply: " + line);
-                    expresult = returnCode4;
-                }
+                Utils.waitForCondition(
+                        () -> {
+                            log2("......sending to the debuggee: 'check_alive'");
+                            log2("       expected reply: 'not_alive'");
+                            pipe.println("check_alive");
+                            String reply = pipe.readln();
+                            if (reply.equals("alive")) {
+                                log3("ERROR: thread2 is alive");
+                                return false;
+                            } else if (reply.equals("not_alive")) {
+                                log2("     thread2 is not alive");
+                                return true;
+                            } else {
+                                log3("ERROR: unexpected reply: " + reply);
+                                throw new RuntimeException("ERROR: unexpected reply: " + reply);
+                            }
 
+                        },
+                        Utils.adjustTimeout(waitTime * 60000),
+                        1000);
+                pipe.println("check_done");
             }
             //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose002a.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -125,18 +125,26 @@
                              }
                          }
                          log1("mainThread is out of: synchronized (lockingObject)");
-
-                         instruction = pipe.readln();
-                         if (!instruction.equals("check_alive")) {
-                             logErr("ERROR: unexpected instruction: " + instruction);
-                             exitCode = FAILED;
-                         } else {
-                             log1("checking on: thread2.isAlive");
-                             if (test_thread.isAlive()) {
-                                 pipe.println("alive");
-                                 test_thread.interrupt();
+                         while (true) {
+                             instruction = pipe.readln();
+                             if (instruction.equals("check_done")) {
+                                 if (test_thread.isAlive()) {
+                                     logErr("ERROR: thread thread2 is still alive");
+                                     exitCode = FAILED;
+                                 }
+                                 break;
+                             } else if (instruction.equals("check_alive")) {
+                                 log1("checking on: thread2.isAlive");
+                                 if (test_thread.isAlive()) {
+                                     pipe.println("alive");
+                                     test_thread.interrupt();
+                                 } else {
+                                     pipe.println("not_alive");
+                                 }
                              } else {
-                                 pipe.println("not_alive");
+                                 logErr("ERROR: unexpected instruction: " + instruction);
+                                 exitCode = FAILED;
+                                 break;
                              }
                          }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003.java	Thu Feb 28 13:12:26 2019 -0800
@@ -23,6 +23,7 @@
 
 package nsk.jdi.VirtualMachine.dispose;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -179,6 +180,7 @@
 
             int expresult = returnCode0;
 
+
             String threadName = "testedThread";
 
             List            allThreads   = null;
@@ -236,28 +238,28 @@
                 if (expresult != returnCode0)
                     break label1;
 
-                log2("      Thread.sleep(waitTime*60000);");
-                try {
-                    Thread.sleep(waitTime*60000);
-                } catch ( InterruptedException e ) {
-                    log3("ERROR: InterruptedException");
-                    expresult = returnCode1;
-                    break label1;
-                }
+                log2("      Waiting for thread2 is not alive");
 
-                log2("......sending to the debuggee: 'check_alive'");
-                log2("       expected reply: 'not_alive'");
-                pipe.println("check_alive");
-                line = pipe.readln();
-                if (line.equals("alive")) {
-                    log3("ERROR: thread2 is alive");
-                    expresult = returnCode1;
-                } else if (line.equals("not_alive")) {
-                    log2("     thread2 is not alive");
-                } else {
-                    log3("ERROR: unexpected reply: " + line);
-                    expresult = returnCode4;
-                }
+                Utils.waitForCondition(
+                        () -> {
+                            log2("......sending to the debuggee: 'check_alive'");
+                            log2("       expected reply: 'not_alive'");
+                            pipe.println("check_alive");
+                            String reply = pipe.readln();
+                            if (reply.equals("alive")) {
+                                log3("ERROR: thread2 is alive");
+                                return false;
+                            } else if (reply.equals("not_alive")) {
+                                log2("     thread2 is not alive");
+                                return true;
+                            } else {
+                                log3("ERROR: unexpected reply: " + reply);
+                                throw new RuntimeException("ERROR: unexpected reply: " + reply);
+                            }
+                        },
+                        Utils.adjustTimeout(waitTime * 60000),
+                        1000);
+                pipe.println("check_done");
 
             }
 
@@ -287,4 +289,6 @@
         }
         return testExitCode;
     }
+
+
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose003a.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -126,17 +126,26 @@
                          }
                          log1("mainThread is out of: synchronized (lockingObject)");
 
-                         instruction = pipe.readln();
-                         if (!instruction.equals("check_alive")) {
-                             logErr("ERROR: unexpected instruction: " + instruction);
-                             exitCode = FAILED;
-                         } else {
-                             log1("checking on: thread2.isAlive");
-                             if (test_thread.isAlive()) {
-                                 test_thread.resume();
-                                 pipe.println("alive");
+                         while (true) {
+                             instruction = pipe.readln();
+                             if (instruction.equals("check_done")) {
+                                 if (test_thread.isAlive()) {
+                                     logErr("ERROR: thread2 thread is still alive");
+                                     exitCode = FAILED;
+                                 }
+                                 break;
+                             } else if (instruction.equals("check_alive")) {
+                                 log1("checking on: thread2.isAlive");
+                                 if (test_thread.isAlive()) {
+                                     test_thread.resume();
+                                     pipe.println("alive");
+                                 } else {
+                                     pipe.println("not_alive");
+                                 }
                              } else {
-                                 pipe.println("not_alive");
+                                 logErr("ERROR: unexpected instruction: " + instruction);
+                                 exitCode = FAILED;
+                                 break;
                              }
                          }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004.java	Thu Feb 28 13:12:26 2019 -0800
@@ -23,6 +23,7 @@
 
 package nsk.jdi.VirtualMachine.dispose;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -261,29 +262,30 @@
                 if (expresult != returnCode0)
                     break label1;
 
-                log2("      Thread.sleep(waitTime*60000);");
-                try {
-                    Thread.sleep(waitTime*60000);
-                } catch ( InterruptedException e ) {
-                    log3("ERROR: InterruptedException");
-                    expresult = returnCode1;
-                    break label1;
-                }
+                log2("      Waiting for thread2 is not alive");
 
-                log2("......sending to the debuggee: 'check_alive'");
-                log2("       expected reply: 'not_alive'");
-                pipe.println("check_alive");
-                line = pipe.readln();
-                if (line.equals("alive")) {
-                    log3("ERROR: thread2 is alive");
-                    expresult = returnCode1;
-                } else if (line.equals("not_alive")) {
-                    log2("     thread2 is not alive");
-                } else {
-                    log3("ERROR: unexpected reply: " + line);
-                    expresult = returnCode4;
-                }
+                Utils.waitForCondition(
+                        () -> {
+                            log2("......sending to the debuggee: 'check_alive'");
+                            log2("       expected reply: 'not_alive'");
+                            pipe.println("check_alive");
+                            String reply = pipe.readln();
+                            if (reply.equals("alive")) {
+                                log3("ERROR: thread2 is alive");
+                                return false;
+                            } else if (reply.equals("not_alive")) {
+                                log2("     thread2 is not alive");
+                                return true;
+                            } else {
+                                log3("ERROR: unexpected reply: " + reply);
+                                throw new RuntimeException("ERROR: unexpected reply: " + reply);
+                            }
 
+                        },
+                        Utils.adjustTimeout(waitTime * 60000),
+                        1000);
+
+                pipe.println("check_done");
             }
 
             //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/dispose/dispose004a.java	Thu Feb 28 13:12:26 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -127,18 +127,26 @@
                              }
                          }
                          log1("mainThread is out of: synchronized (lockingObject)");
-
-                         instruction = pipe.readln();
-                         if (!instruction.equals("check_alive")) {
-                             logErr("ERROR: unexpected instruction: " + instruction);
-                             exitCode = FAILED;
-                         } else {
-                             log1("checking on: thread2.isAlive");
-                             if (test_thread.isAlive()) {
-                                 test_thread.resume();
-                                 pipe.println("alive");
+                         while (true) {
+                             instruction = pipe.readln();
+                             if (instruction.equals("check_done")) {
+                                 if (test_thread.isAlive()) {
+                                     logErr("thread thread2 is still alive");
+                                     exitCode = FAILED;
+                                 }
+                                 break;
+                             } else if (instruction.equals("check_alive")) {
+                                 log1("checking on: thread2.isAlive");
+                                 if (test_thread.isAlive()) {
+                                     test_thread.resume();
+                                     pipe.println("alive");
+                                 } else {
+                                     pipe.println("not_alive");
+                                 }
                              } else {
-                                 pipe.println("not_alive");
+                                 logErr("ERROR: unexpected instruction: " + instruction);
+                                 exitCode = FAILED;
+                                 break;
                              }
                          }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/suspend/suspend001.java	Thu Feb 28 12:05:59 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/suspend/suspend001.java	Thu Feb 28 13:12:26 2019 -0800
@@ -23,6 +23,7 @@
 
 package nsk.jdi.VirtualMachine.suspend;
 
+import jdk.test.lib.Utils;
 import nsk.share.*;
 import nsk.share.jpda.*;
 import nsk.share.jdi.*;
@@ -318,9 +319,10 @@
                 eventSet1.resume();
                 eventSet.resume();
 
-                log2("       before: Thread.sleep(waitTime*60000);");
+                log2("       before: Thread.sleep(waitTime*1000);");
+
                 try {
-                    Thread.sleep(waitTime*60000);
+                    Thread.sleep(Utils.adjustTimeout(waitTime*1000));
                 } catch ( InterruptedException e ) {
                     log3("ERROR: InterruptedException");
                     expresult = returnCode1;