6961894: TEST_BUG: jdk_lang tests fail in samevm mode
authormchung
Fri, 18 Jun 2010 09:35:22 -0700
changeset 5808 3a1f603c5ca7
parent 5807 d34ed576e234
child 5809 6e38efd0293f
6961894: TEST_BUG: jdk_lang tests fail in samevm mode Summary: Fixed jdk_lang tests to run in samevm mode or mark to run in othervm Reviewed-by: alanb
jdk/test/ProblemList.txt
jdk/test/java/lang/System/ExitFinalizersAndJIT.java
jdk/test/java/lang/Thread/GenerifyStackTraces.java
jdk/test/java/lang/Thread/StackTraces.java
jdk/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java
jdk/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java
jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java
jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java
jdk/test/java/lang/management/MemoryMXBean/Pending.java
jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
jdk/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java
jdk/test/java/lang/management/RuntimeMXBean/UpTime.java
jdk/test/java/lang/management/ThreadMXBean/AllThreadIds.java
jdk/test/java/lang/management/ThreadMXBean/DisableTest.java
jdk/test/java/lang/management/ThreadMXBean/EnableTest.java
jdk/test/java/lang/management/ThreadMXBean/FindDeadlocks.java
jdk/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java
jdk/test/java/lang/management/ThreadMXBean/Locks.java
jdk/test/java/lang/reflect/Proxy/Boxing.java
jdk/test/java/lang/reflect/Proxy/ClassRestrictions.java
jdk/test/java/lang/reflect/Proxy/returnTypes/Test.java
--- a/jdk/test/ProblemList.txt	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/ProblemList.txt	Fri Jun 18 09:35:22 2010 -0700
@@ -337,68 +337,12 @@
 
 # jdk_lang
 
-# Some of these tests (like java/lang/management) may just need to be marked
-#   othervm, but that is partially speculation.
-
 # Times out on solaris 10 sparc
 java/lang/ClassLoader/Assert.java				generic-all
 
-# Fedora 9 X64, RuntimeException: MyThread expected to be blocked on lock, but got null
-java/lang/management/ThreadMXBean/ThreadStateTest.java 		generic-all
-
-# RuntimeException: Uptime of the JVM is more than 30 minutes (32 minutes).
-java/lang/management/RuntimeMXBean/UpTime.java			generic-all
-
 # Solaris sparc, samevm, java.lang.Exception: Read from closed pipe hangs
 java/lang/Runtime/exec/SleepyCat.java				generic-all
 
-# Fedora 9 32bit, -client, samevm, Error while cleaning up threads after test
-java/lang/management/ThreadMXBean/Locks.java			generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/management/ClassLoadingMXBean/LoadCounts.java		generic-all
-java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java generic-all
-java/lang/management/ManagementFactory/MXBeanProxyTest.java	generic-all
-java/lang/management/ManagementFactory/ThreadMXBeanProxy.java	generic-all
-java/lang/management/MemoryMXBean/CollectionUsageThreshold.java	generic-all
-java/lang/management/MemoryMXBean/GetMBeanInfo.java		generic-all
-java/lang/management/MemoryMXBean/LowMemoryTest.java		generic-all
-java/lang/management/MemoryMXBean/MemoryManagement.java		generic-all
-java/lang/management/MemoryMXBean/MemoryTest.java		generic-all
-java/lang/management/MemoryMXBean/Pending.java			generic-all
-
-# Problematic on all platforms (even as othervm)
-java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java 	generic-all
-
-# Causes jtreg exit samevm issues due to non-String object in system properties
-java/lang/management/RuntimeMXBean/GetSystemProperties.java 	generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/management/RuntimeMXBean/PropertiesTest.java		generic-all
-java/lang/management/ThreadMXBean/AllThreadIds.java		generic-all
-java/lang/management/ThreadMXBean/EnableTest.java		generic-all
-java/lang/management/ThreadMXBean/FindMonitorDeadlock.java	generic-all
-java/lang/management/ThreadMXBean/LockingThread.java		generic-all
-java/lang/management/ThreadMXBean/MonitorDeadlock.java		generic-all
-java/lang/management/ThreadMXBean/MyOwnSynchronizer.java	generic-all
-java/lang/management/ThreadMXBean/SharedSynchronizer.java	generic-all
-java/lang/management/ThreadMXBean/SynchronizerLockingThread.java generic-all
-java/lang/management/ThreadMXBean/ThreadCounts.java		generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/reflect/Proxy/Boxing.java				generic-all
-java/lang/reflect/Proxy/ClassRestrictions.java			generic-all
-java/lang/reflect/Proxy/returnTypes/Test.java			generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
-java/lang/Runtime/exec/LotsOfOutput.java			generic-all
-java/lang/System/ExitFinalizersAndJIT.java			generic-all
-java/lang/System/finalization/FinThreads.java			generic-all
-java/lang/Thread/GenerifyStackTraces.java			generic-all
-java/lang/Thread/StackTraces.java				generic-all
-java/lang/ThreadGroup/Daemon.java				generic-all
-java/lang/ThreadGroup/NullThreadName.java			generic-all
-
 # Times out on solaris sparc -server
 java/lang/ThreadLocal/MemoryLeak.java			 	solaris-all
 
@@ -415,9 +359,6 @@
 # Access denied messages on windows/mks, filed 6954450
 sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh	windows-all
 
-# Filed 6951284, fails on linux 64bit Fedora 9, peak thread count differences
-java/lang/management/ThreadMXBean/ResetPeakThreadCount.java	generic-all
-
 # Started failing on linux and solaris (filed 6950927)
 #   com.sun.tools.attach.AttachNotSupportedException:
 #     Unable to open socket file:
@@ -1166,12 +1107,6 @@
 #   11 separate stacktraces created... file reuse problem?
 java/util/zip/ZipFile/ReadLongZipFileName.java			generic-all
 
-# Recent failure on all platforms
-sun/util/resources/TimeZone/Bug6317929.java			generic-all
-
-# Fails with -ea -esa on all platforms with Assertion error
-java/util/ResourceBundle/Test4300693.java			generic-all
-
 # Failing on all -client 32bit platforms starting with b77? See 6908348.
 java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java generic-all
 
@@ -1199,10 +1134,6 @@
 java/util/Formatter/Constructors.java				generic-all
 
 # Need to be marked othervm, or changed to be samevm safe
-java/util/Locale/Bug4175998Test.java				generic-all
-java/util/Locale/LocaleTest.java				generic-all
-
-# Need to be marked othervm, or changed to be samevm safe
 java/util/WeakHashMap/GCDuringIteration.java			generic-all
 
 ############################################################################
--- a/jdk/test/java/lang/System/ExitFinalizersAndJIT.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/System/ExitFinalizersAndJIT.java	Fri Jun 18 09:35:22 2010 -0700
@@ -26,6 +26,7 @@
    @summary runFinalizersOnExit(true) causes JIT to be unloaded and
             crashes the VM.  Interim fix for 1.2 beta4 -- don't unload
             native libraries loaded by system classes.
+   @run main/othervm ExitFinalizersAndJIT
 */
 
 public class ExitFinalizersAndJIT {
--- a/jdk/test/java/lang/Thread/GenerifyStackTraces.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/Thread/GenerifyStackTraces.java	Fri Jun 18 09:35:22 2010 -0700
@@ -155,7 +155,7 @@
             printStack(t, stack);
         }
         int frame = stack.length - 1;
-        for (int i = 0; i < depth; i++) {
+        for (int i = 0; i < depth && frame >= 0; i++) {
             if (! stack[frame].getMethodName().equals(methodNames[i])) {
                 throw new RuntimeException("Expected " + methodNames[i] +
                                            " in frame " + frame + " but got " +
--- a/jdk/test/java/lang/Thread/StackTraces.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/Thread/StackTraces.java	Fri Jun 18 09:35:22 2010 -0700
@@ -159,7 +159,7 @@
             printStack(t, stack);
         }
         int frame = stack.length - 1;
-        for (int i = 0; i < depth; i++) {
+        for (int i = 0; i < depth && frame >= 0; i++) {
             if (! stack[frame].getMethodName().equals(methodNames[i])) {
                 throw new RuntimeException("Expected " + methodNames[i] +
                                            " in frame " + frame + " but got " +
--- a/jdk/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ClassLoadingMXBean/LoadCounts.java	Fri Jun 18 09:35:22 2010 -0700
@@ -118,9 +118,21 @@
 }
 class Slave {}
 
-class LeftHand extends ClassLoader {}
-class RightHand extends ClassLoader {}
+class LeftHand extends ClassLoader {
+    public LeftHand() {
+        super(LeftHand.class.getClassLoader());
+    }
+}
+class RightHand extends ClassLoader {
+    public RightHand() {
+        super(RightHand.class.getClassLoader());
+    }
+}
 class Body {}
 
-class LoaderForTwoInstances extends ClassLoader {}
+class LoaderForTwoInstances extends ClassLoader {
+    public LoaderForTwoInstances() {
+        super(LoaderForTwoInstances.class.getClassLoader());
+    }
+}
 class TheSameClass {}
--- a/jdk/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ManagementFactory/MXBeanProxyTest.java	Fri Jun 18 09:35:22 2010 -0700
@@ -25,6 +25,7 @@
  * @test
  * @bug     5024531
  * @summary Basic Test for ManagementFactory.newPlatformMXBean().
+ * @run main/othervm MXBeanProxyTest
  * @author  Mandy Chung
  */
 import javax.management.*;
--- a/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/MemoryMXBean/CollectionUsageThreshold.java	Fri Jun 18 09:35:22 2010 -0700
@@ -41,9 +41,9 @@
 
 public class CollectionUsageThreshold {
     private static MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
-    private static List pools = ManagementFactory.getMemoryPoolMXBeans();
-    private static List managers = ManagementFactory.getMemoryManagerMXBeans();
-    private static Map result = new HashMap();
+    private static List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
+    private static List<MemoryManagerMXBean> managers = ManagementFactory.getMemoryManagerMXBeans();
+    private static Map<String, PoolRecord> result = new HashMap<>();
     private static boolean trace = false;
     private static boolean testFailed = false;
     private static final int EXPECTED_NUM_POOLS = 2;
@@ -119,8 +119,7 @@
         }
 
         // Find the Old generation which supports low memory detection
-        for (ListIterator iter = pools.listIterator(); iter.hasNext(); ) {
-            MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
+        for (MemoryPoolMXBean p : pools) {
             MemoryUsage u = p.getUsage();
             if (p.isUsageThresholdSupported() && p.isCollectionUsageThresholdSupported()) {
                 PoolRecord pr = new PoolRecord(p);
@@ -134,25 +133,30 @@
             throw new RuntimeException("Unexpected number of selected pools");
         }
 
-        checker = new Checker("Checker thread");
-        checker.setDaemon(true);
-        checker.start();
+        try {
+            checker = new Checker("Checker thread");
+            checker.setDaemon(true);
+            checker.start();
+
+            for (PoolRecord pr : result.values()) {
+                pr.getPool().setCollectionUsageThreshold(THRESHOLD);
+                System.out.println("Collection usage threshold of " +
+                    pr.getPool().getName() + " set to " + THRESHOLD);
+            }
 
-        for (Iterator iter = result.values().iterator(); iter.hasNext();) {
-            PoolRecord pr = (PoolRecord) iter.next();
-            pr.getPool().setCollectionUsageThreshold(THRESHOLD);
-            System.out.println("Collection usage threshold of " +
-                pr.getPool().getName() + " set to " + THRESHOLD);
-        }
+            SensorListener listener = new SensorListener();
+            NotificationEmitter emitter = (NotificationEmitter) mm;
+            emitter.addNotificationListener(listener, null, null);
 
-        SensorListener listener = new SensorListener();
-        NotificationEmitter emitter = (NotificationEmitter) mm;
-        emitter.addNotificationListener(listener, null, null);
-
-        mm.setVerbose(true);
-        for (int i = 0; i < NUM_GCS; i++) {
-            invokeGC();
-            checker.waitForCheckResult();
+            for (int i = 0; i < NUM_GCS; i++) {
+                invokeGC();
+                checker.waitForCheckResult();
+            }
+        } finally {
+            // restore the default
+            for (PoolRecord pr : result.values()) {
+                pr.getPool().setCollectionUsageThreshold(0);
+            }
         }
 
         if (testFailed)
@@ -168,8 +172,7 @@
         mm.gc();
 
         if (trace) {
-            for (Iterator iter = result.values().iterator(); iter.hasNext();) {
-                PoolRecord pr = (PoolRecord) iter.next();
+            for (PoolRecord pr : result.values()) {
                 System.out.println("Usage after GC for: " + pr.getPool().getName());
                 MemoryUtil.printMemoryUsage(pr.getPool().getUsage());
             }
@@ -200,8 +203,7 @@
             }
         }
         private void checkResult() {
-            for (Iterator iter = result.values().iterator(); iter.hasNext();) {
-                PoolRecord pr = (PoolRecord) iter.next();
+            for (PoolRecord pr : result.values()) {
                 if (pr.getListenerInvokedCount() != numGCs) {
                     throw new RuntimeException("Listeners invoked count = " +
                          pr.getListenerInvokedCount() + " expected to be " +
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Fri Jun 18 09:35:22 2010 -0700
@@ -31,7 +31,7 @@
  * @author  Mandy Chung
  *
  * @build LowMemoryTest MemoryUtil
- * @run main/timeout=600 LowMemoryTest
+ * @run main/othervm/timeout=600 LowMemoryTest
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/MemoryMXBean/MemoryManagement.java	Fri Jun 18 09:35:22 2010 -0700
@@ -31,7 +31,7 @@
  * @author  Mandy Chung
  *
  * @build MemoryManagement MemoryUtil
- * @run main/timeout=600 MemoryManagement
+ * @run main/othervm/timeout=600 MemoryManagement
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/MemoryMXBean/Pending.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/MemoryMXBean/Pending.java	Fri Jun 18 09:35:22 2010 -0700
@@ -62,9 +62,21 @@
             trace = true;
         }
 
-        // Turn on verbose:gc to track GC
-        mbean.setVerbose(true);
+        try {
+            if (trace) {
+                // Turn on verbose:gc to track GC
+                mbean.setVerbose(true);
+            }
+            test();
+        } finally {
+            if (trace) {
+                mbean.setVerbose(false);
+            }
+        }
+        System.out.println("Test passed.");
+    }
 
+    private static void test() throws Exception {
         // Clean the memory and remove all objects that are pending
         // finalization
         System.gc();
@@ -130,7 +142,6 @@
                                      + " end = " + snapshot);
         }
 
-        System.out.println("Test passed.");
     }
 
     private static void checkFinalizerCount(int expectedTotal, int curFinalized)
--- a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	Fri Jun 18 09:35:22 2010 -0700
@@ -28,7 +28,7 @@
  * @author  Mandy Chung
  *
  * @build ResetPeakMemoryUsage MemoryUtil
- * @run main ResetPeakMemoryUsage
+ * @run main/othervm ResetPeakMemoryUsage
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/MemoryPoolMXBean/ThresholdTest.java	Fri Jun 18 09:35:22 2010 -0700
@@ -37,11 +37,23 @@
 public class ThresholdTest {
     public static void main(String args[]) throws Exception {
         List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
-        for (MemoryPoolMXBean p : pools) {
-            // verify if isUsageThresholdExceeded() returns correct value
-            checkUsageThreshold(p);
-            // verify if isCollectionUsageThresholdExceeded() returns correct value
-            checkCollectionUsageThreshold(p);
+        try {
+            for (MemoryPoolMXBean p : pools) {
+                // verify if isUsageThresholdExceeded() returns correct value
+                checkUsageThreshold(p);
+                // verify if isCollectionUsageThresholdExceeded() returns correct value
+                checkCollectionUsageThreshold(p);
+            }
+        } finally {
+            // restore the default
+            for (MemoryPoolMXBean p : pools) {
+                if (p.isUsageThresholdSupported()) {
+                    p.setUsageThreshold(0);
+                }
+                if (p.isCollectionUsageThresholdSupported()) {
+                    p.setCollectionUsageThreshold(0);
+                }
+            }
         }
 
         System.out.println("Test passed.");
--- a/jdk/test/java/lang/management/RuntimeMXBean/UpTime.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/RuntimeMXBean/UpTime.java	Fri Jun 18 09:35:22 2010 -0700
@@ -37,13 +37,18 @@
         = ManagementFactory.getRuntimeMXBean();
 
     public static void main(String argv[]) throws Exception {
+        long jvmStartTime = metrics.getStartTime();
         long systemStartOuter = System.currentTimeMillis();
         long metricsStart = metrics.getUptime();
         long systemStartInner = System.currentTimeMillis();
 
+        // This JVM might have been running for some time if this test runs
+        // in samevm mode.  The sanity check should apply to the test uptime.
+        long testUptime = metricsStart - (systemStartOuter - jvmStartTime);
+
         // If uptime is more than 30 minutes then it looks like a bug in
         // the method
-        if (metricsStart > TIMEOUT * 60 * 1000)
+        if (testUptime > TIMEOUT * 60 * 1000)
             throw new RuntimeException("Uptime of the JVM is more than 30 "
                                      + "minutes ("
                                      + (metricsStart / 60 / 1000)
--- a/jdk/test/java/lang/management/ThreadMXBean/AllThreadIds.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ThreadMXBean/AllThreadIds.java	Fri Jun 18 09:35:22 2010 -0700
@@ -28,7 +28,7 @@
  * @author  Alexei Guibadoulline and Mandy Chung
  *
  * @run build Barrier
- * @run main AllThreadIds
+ * @run main/othervm AllThreadIds
  */
 
 import java.lang.management.*;
@@ -70,6 +70,12 @@
         }
     }
 
+    private static void fail(String msg) {
+        trace = true;
+        printThreadList();
+        throw new RuntimeException(msg);
+    }
+
     private static void checkThreadCount(int numNewThreads,
                                          int numTerminatedThreads)
         throws Exception {
@@ -82,27 +88,27 @@
 
         if ((curLiveThreadCount - prevLiveThreadCount) !=
             (numNewThreads - numTerminatedThreads)) {
-            throw new RuntimeException("Unexpected number of live threads: " +
-                " Prev Total = " + prevTotalThreadCount +
-                " Current Total = " + curTotalThreadCount +
+            fail("Unexpected number of live threads: " +
+                " Prev live = " + prevLiveThreadCount +
+                " Current live = " + curLiveThreadCount +
                 " Threads added = " + numNewThreads +
                 " Threads terminated = " + numTerminatedThreads);
         }
         if (curPeakThreadCount - prevPeakThreadCount != numNewThreads) {
-            throw new RuntimeException("Unexpected number of peak threads: " +
-                " Prev Total = " + prevTotalThreadCount +
-                " Current Total = " + curTotalThreadCount +
+            fail("Unexpected number of peak threads: " +
+                " Prev peak = " + prevPeakThreadCount +
+                " Current peak = " + curPeakThreadCount +
                 " Threads added = " + numNewThreads);
         }
         if (curTotalThreadCount - prevTotalThreadCount != numNewThreads) {
-            throw new RuntimeException("Unexpected number of total threads: " +
+            fail("Unexpected number of total threads: " +
                 " Prev Total = " + prevTotalThreadCount +
                 " Current Total = " + curTotalThreadCount +
                 " Threads added = " + numNewThreads);
         }
         long[] list = mbean.getAllThreadIds();
         if (list.length != curLiveThreadCount) {
-            throw new RuntimeException("Array length returned by " +
+            fail("Array length returned by " +
                 "getAllThreadIds() = " + list.length +
                 " not matched count = " + curLiveThreadCount);
         }
--- a/jdk/test/java/lang/management/ThreadMXBean/DisableTest.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ThreadMXBean/DisableTest.java	Fri Jun 18 09:35:22 2010 -0700
@@ -36,8 +36,18 @@
     private static ThreadMXBean tm = ManagementFactory.getThreadMXBean();
 
     public static void main(String args[]) throws Exception {
-        testThreadContentionMonitoring();
-        testThreadCpuMonitoring();
+        try {
+            testThreadContentionMonitoring();
+            testThreadCpuMonitoring();
+        } finally {
+            // restore the default
+            if (tm.isThreadContentionMonitoringSupported()) {
+                tm.setThreadContentionMonitoringEnabled(false);
+            }
+            if (tm.isThreadCpuTimeSupported()) {
+                tm.setThreadCpuTimeEnabled(false);
+            }
+        }
 
         System.out.println("Test passed.");
     }
--- a/jdk/test/java/lang/management/ThreadMXBean/EnableTest.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ThreadMXBean/EnableTest.java	Fri Jun 18 09:35:22 2010 -0700
@@ -119,8 +119,19 @@
     }
 
     public static void main(String args[]) throws Exception {
-        testThreadContentionMonitoring();
-        testThreadCpuTime();
+        try {
+            testThreadContentionMonitoring();
+            testThreadCpuTime();
+        } finally {
+            // restore the default
+            if (tm.isThreadContentionMonitoringSupported()) {
+                tm.setThreadContentionMonitoringEnabled(false);
+            }
+            if (tm.isThreadCpuTimeSupported()) {
+                tm.setThreadCpuTimeEnabled(false);
+            }
+        }
+
 
         System.out.println("Test passed.");
     }
--- a/jdk/test/java/lang/management/ThreadMXBean/FindDeadlocks.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ThreadMXBean/FindDeadlocks.java	Fri Jun 18 09:35:22 2010 -0700
@@ -33,7 +33,7 @@
  * @build MonitorDeadlock
  * @build SynchronizerDeadlock
  * @build ThreadDump
- * @run main FindDeadlocks
+ * @run main/othervm FindDeadlocks
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ThreadMXBean/FindMonitorDeadlock.java	Fri Jun 18 09:35:22 2010 -0700
@@ -30,7 +30,7 @@
  *
  * @build MonitorDeadlock
  * @build ThreadDump
- * @run main FindMonitorDeadlock
+ * @run main/othervm FindMonitorDeadlock
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java	Fri Jun 18 09:35:22 2010 -0700
@@ -29,7 +29,7 @@
  * @author  Mandy Chung
  *
  * @build ThreadExecutionSynchronizer
- * @run main Locks
+ * @run main/othervm Locks
  */
 
 import java.lang.management.*;
--- a/jdk/test/java/lang/reflect/Proxy/Boxing.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/reflect/Proxy/Boxing.java	Fri Jun 18 09:35:22 2010 -0700
@@ -71,8 +71,8 @@
         Random random = new Random(42); // ensure consistent test domain
 
         Test proxy = (Test) Proxy.newProxyInstance(
-            ClassLoader.getSystemClassLoader(),
-            new Class[] { Test.class },
+            Test.class.getClassLoader(),
+            new Class<?>[] { Test.class },
             new TestHandler());
 
         for (int rep = 0; rep < REPS; rep++) {
--- a/jdk/test/java/lang/reflect/Proxy/ClassRestrictions.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/reflect/Proxy/ClassRestrictions.java	Fri Jun 18 09:35:22 2010 -0700
@@ -54,16 +54,16 @@
             "\nTest of restrictions on parameters to Proxy.getProxyClass\n");
 
         try {
-            ClassLoader loader = ClassLoader.getSystemClassLoader();
-            Class[] interfaces;
-            Class proxyClass;
+            ClassLoader loader = ClassRestrictions.class.getClassLoader();
+            Class<?>[] interfaces;
+            Class<?> proxyClass;
 
             /*
              * All of the Class objects in the interfaces array must represent
              * interfaces, not classes or primitive types.
              */
             try {
-                interfaces = new Class[] { Object.class };
+                interfaces = new Class<?>[] { Object.class };
                 proxyClass = Proxy.getProxyClass(loader, interfaces);
                 throw new RuntimeException(
                     "proxy class created with java.lang.Object as interface");
@@ -73,7 +73,7 @@
                 // assume exception is for intended failure
             }
             try {
-                interfaces = new Class[] { Integer.TYPE };
+                interfaces = new Class<?>[] { Integer.TYPE };
                 proxyClass = Proxy.getProxyClass(loader, interfaces);
                 throw new RuntimeException(
                     "proxy class created with int.class as interface");
@@ -88,7 +88,7 @@
              * Class objects.
              */
             try {
-                interfaces = new Class[] { Bar.class, Bar.class };
+                interfaces = new Class<?>[] { Bar.class, Bar.class };
                 proxyClass = Proxy.getProxyClass(loader, interfaces);
                 throw new RuntimeException(
                     "proxy class created with repeated interfaces");
@@ -107,7 +107,7 @@
             Class altBarClass;
             altBarClass = Class.forName(Bar.class.getName(), false, altLoader);
             try {
-                interfaces = new Class[] { altBarClass };
+                interfaces = new Class<?>[] { altBarClass };
                 proxyClass = Proxy.getProxyClass(loader, interfaces);
                 throw new RuntimeException(
                     "proxy class created with interface " +
@@ -121,8 +121,8 @@
             /*
              * All non-public interfaces must be in the same package.
              */
-            Class nonPublic1 = Bashful.class;
-            Class nonPublic2 = null;
+            Class<?> nonPublic1 = Bashful.class;
+            Class<?> nonPublic2 = null;
             String[] nonPublicInterfaces = new String[] {
                 "java.awt.Conditional",
                 "java.util.zip.ZipConstants",
@@ -147,7 +147,7 @@
                     "no second non-public interface found for test");
             }
             try {
-                interfaces = new Class[] { nonPublic1, nonPublic2 };
+                interfaces = new Class<?>[] { nonPublic1, nonPublic2 };
                 proxyClass = Proxy.getProxyClass(loader, interfaces);
                 throw new RuntimeException(
                     "proxy class created with two non-public interfaces " +
@@ -163,7 +163,7 @@
              * parameter signature but different return type.
              */
             try {
-                interfaces = new Class[] { Bar.class, Baz.class };
+                interfaces = new Class<?>[] { Bar.class, Baz.class };
                 proxyClass = Proxy.getProxyClass(loader, interfaces);
                 throw new RuntimeException(
                     "proxy class created with conflicting methods");
--- a/jdk/test/java/lang/reflect/Proxy/returnTypes/Test.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/reflect/Proxy/returnTypes/Test.java	Fri Jun 18 09:35:22 2010 -0700
@@ -42,7 +42,7 @@
 
     // additional test cases may be added to both of these lists:
 
-    private static final Class[][] GOOD = {
+    private static final Class<?>[][] GOOD = {
         { Collection.class },
         { Iterable.class, Collection.class },
         { Iterable.class, Collection.class, List.class },
@@ -51,7 +51,7 @@
           GetArray.class }
     };
 
-    private static final Class[][] BAD = {
+    private static final Class<?>[][] BAD = {
         { Runnable.class, PrivilegedAction.class },
         { GetSerializable.class, GetCloneable.class },
         { GetObject.class, GetSerializable.class, GetCloneable.class }
@@ -60,12 +60,12 @@
     public static void main(String[] args) throws Exception {
         System.err.println("\nRegression test for bug 4838310\n");
 
-        ClassLoader loader = ClassLoader.getSystemClassLoader();
+        ClassLoader loader = Test.class.getClassLoader();
 
         System.err.println("Testing GOOD combinations:");
 
         for (int i = 0; i < GOOD.length; i++) {
-            Class[] interfaces = GOOD[i];
+            Class<?>[] interfaces = GOOD[i];
             System.err.println(Arrays.asList(interfaces));
             Proxy.getProxyClass(loader, interfaces);
             System.err.println("--- OK.");
@@ -74,7 +74,7 @@
         System.err.println("Testing BAD combinations:");
 
         for (int i = 0; i < BAD.length; i++) {
-            Class[] interfaces = BAD[i];
+            Class<?>[] interfaces = BAD[i];
             System.err.println(Arrays.asList(interfaces));
             try {
                 Proxy.getProxyClass(loader, interfaces);