8232370: Refactor some com.sun.jdi tests to enable IDE integration
authorclanger
Thu, 17 Oct 2019 22:41:36 +0200 (2019-10-17)
changeset 58681 5f14a659a8cb
parent 58676 92e7d617897e
child 58682 9f5b92d5a1b2
8232370: Refactor some com.sun.jdi tests to enable IDE integration Reviewed-by: amenkov, cjplummer, sspitsyn
test/jdk/com/sun/jdi/MonitorEventTest.java
test/jdk/com/sun/jdi/MonitorFrameInfo.java
test/jdk/com/sun/jdi/RedefineImplementor.java
--- a/test/jdk/com/sun/jdi/MonitorEventTest.java	Thu Oct 17 20:56:11 2019 +0200
+++ b/test/jdk/com/sun/jdi/MonitorEventTest.java	Thu Oct 17 22:41:36 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -31,15 +31,22 @@
  * @run compile -g MonitorEventTest.java
  * @run driver MonitorEventTest
  */
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-import com.sun.jdi.request.*;
-
-import java.util.*;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.event.BreakpointEvent;
+import com.sun.jdi.event.MonitorContendedEnterEvent;
+import com.sun.jdi.event.MonitorContendedEnteredEvent;
+import com.sun.jdi.event.MonitorWaitEvent;
+import com.sun.jdi.event.MonitorWaitedEvent;
+import com.sun.jdi.request.EventRequest;
+import com.sun.jdi.request.MonitorContendedEnterRequest;
+import com.sun.jdi.request.MonitorContendedEnteredRequest;
+import com.sun.jdi.request.MonitorWaitRequest;
+import com.sun.jdi.request.MonitorWaitedRequest;
 
 /********** target program **********/
 
-class MonitorTestTarg {
+class MonitorEventTestTarg {
     public static Object endingMonitor;
     public static Object startingMonitor;
     public static final long timeout = 30 * 6000; // milliseconds
@@ -91,13 +98,13 @@
 
 class myThread extends Thread {
     public void run() {
-        synchronized(MonitorTestTarg.startingMonitor) {
-            MonitorTestTarg.startingMonitor.notify();
+        synchronized(MonitorEventTestTarg.startingMonitor) {
+            MonitorEventTestTarg.startingMonitor.notify();
         }
 
         // contended enter wait until main thread release monitor
-        MonitorTestTarg.aboutEnterLock = true;
-        synchronized (MonitorTestTarg.endingMonitor) {
+        MonitorEventTestTarg.aboutEnterLock = true;
+        synchronized (MonitorEventTestTarg.endingMonitor) {
         }
     }
 }
@@ -108,7 +115,6 @@
 public class MonitorEventTest extends TestScaffold {
     ReferenceType targetClass;
     ThreadReference mainThread;
-    List monitors;
     MonitorContendedEnterRequest contendedEnterRequest;
     MonitorWaitedRequest monitorWaitedRequest;
     MonitorContendedEnteredRequest contendedEnteredRequest;
@@ -160,11 +166,10 @@
          * Get to the top of main()
          * to determine targetClass and mainThread
          */
-        BreakpointEvent bpe = startToMain("MonitorTestTarg");
+        BreakpointEvent bpe = startToMain("MonitorEventTestTarg");
         targetClass = bpe.location().declaringType();
         mainThread = bpe.thread();
 
-        int initialSize = mainThread.frames().size();
         if (vm().canRequestMonitorEvents()) {
             contendedEnterRequest = eventRequestManager().createMonitorContendedEnterRequest();
             contendedEnterRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
@@ -183,7 +188,7 @@
         }
 
 
-        resumeTo("MonitorTestTarg", "foo", "()V");
+        resumeTo("MonitorEventTestTarg", "foo", "()V");
 
         /*
          * resume until end
--- a/test/jdk/com/sun/jdi/MonitorFrameInfo.java	Thu Oct 17 20:56:11 2019 +0200
+++ b/test/jdk/com/sun/jdi/MonitorFrameInfo.java	Thu Oct 17 22:41:36 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -33,15 +33,17 @@
  * @run compile -g MonitorFrameInfo.java
  * @run driver MonitorFrameInfo
  */
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-import com.sun.jdi.request.*;
+import java.util.List;
 
-import java.util.*;
+import com.sun.jdi.InvalidStackFrameException;
+import com.sun.jdi.MonitorInfo;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.event.BreakpointEvent;
 
     /********** target program **********/
 
-class MonitorTestTarg {
+class MonitorFrameInfoTarg {
     static void foo3() {
         System.out.println("executing foo3");
 
@@ -71,7 +73,7 @@
 public class MonitorFrameInfo extends TestScaffold {
     ReferenceType targetClass;
     ThreadReference mainThread;
-    List monitors;
+    List<MonitorInfo> monitors;
 
     static int expectedCount = 2;
     static int[] expectedDepth = { 1, 3 };
@@ -93,13 +95,13 @@
          * Get to the top of main()
          * to determine targetClass and mainThread
          */
-        BreakpointEvent bpe = startToMain("MonitorTestTarg");
+        BreakpointEvent bpe = startToMain("MonitorFrameInfoTarg");
         targetClass = bpe.location().declaringType();
         mainThread = bpe.thread();
 
         int initialSize = mainThread.frames().size();
 
-        resumeTo("MonitorTestTarg", "foo3", "()V");
+        resumeTo("MonitorFrameInfoTarg", "foo3", "()V");
 
         if (!mainThread.frame(0).location().method().name()
                         .equals("foo3")) {
--- a/test/jdk/com/sun/jdi/RedefineImplementor.java	Thu Oct 17 20:56:11 2019 +0200
+++ b/test/jdk/com/sun/jdi/RedefineImplementor.java	Thu Oct 17 22:41:36 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -44,14 +44,14 @@
     }
 
     public static void main(String[] args) {
-        Runnable r = new B();
-        B.func(r);
-        B.func(r);  // @1 breakpoint
+        Runnable r = new RedefineImplementorB();
+        RedefineImplementorB.func(r);
+        RedefineImplementorB.func(r);  // @1 breakpoint
     }
 
 }
 
-class B extends RedefineImplementorTarg {
+class RedefineImplementorB extends RedefineImplementorTarg {
     static void func(Runnable r) {
         r.run();
     }