提交 7ff91a0f 编写于 作者: M mchung

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
上级 b31257d1
...@@ -337,68 +337,12 @@ java/io/StreamTokenizer/Comment.java generic-all ...@@ -337,68 +337,12 @@ java/io/StreamTokenizer/Comment.java generic-all
# jdk_lang # 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 # Times out on solaris 10 sparc
java/lang/ClassLoader/Assert.java generic-all 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 # Solaris sparc, samevm, java.lang.Exception: Read from closed pipe hangs
java/lang/Runtime/exec/SleepyCat.java generic-all 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 # Times out on solaris sparc -server
java/lang/ThreadLocal/MemoryLeak.java solaris-all java/lang/ThreadLocal/MemoryLeak.java solaris-all
...@@ -415,9 +359,6 @@ java/lang/ClassLoader/deadlock/TestCrossDelegate.sh generic-all ...@@ -415,9 +359,6 @@ java/lang/ClassLoader/deadlock/TestCrossDelegate.sh generic-all
# Access denied messages on windows/mks, filed 6954450 # Access denied messages on windows/mks, filed 6954450
sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh windows-all 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) # Started failing on linux and solaris (filed 6950927)
# com.sun.tools.attach.AttachNotSupportedException: # com.sun.tools.attach.AttachNotSupportedException:
# Unable to open socket file: # Unable to open socket file:
...@@ -1166,12 +1107,6 @@ tools/jar/index/MetaInf.java windows-all ...@@ -1166,12 +1107,6 @@ tools/jar/index/MetaInf.java windows-all
# 11 separate stacktraces created... file reuse problem? # 11 separate stacktraces created... file reuse problem?
java/util/zip/ZipFile/ReadLongZipFileName.java generic-all 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. # Failing on all -client 32bit platforms starting with b77? See 6908348.
java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java generic-all java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java generic-all
...@@ -1198,10 +1133,6 @@ java/util/EnumSet/EnumSetBash.java solaris-sparc ...@@ -1198,10 +1133,6 @@ java/util/EnumSet/EnumSetBash.java solaris-sparc
# Failing to close an input stream? "foo", triggers samevm windows failures # Failing to close an input stream? "foo", triggers samevm windows failures
java/util/Formatter/Constructors.java generic-all 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 # Need to be marked othervm, or changed to be samevm safe
java/util/WeakHashMap/GCDuringIteration.java generic-all java/util/WeakHashMap/GCDuringIteration.java generic-all
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
@summary runFinalizersOnExit(true) causes JIT to be unloaded and @summary runFinalizersOnExit(true) causes JIT to be unloaded and
crashes the VM. Interim fix for 1.2 beta4 -- don't unload crashes the VM. Interim fix for 1.2 beta4 -- don't unload
native libraries loaded by system classes. native libraries loaded by system classes.
@run main/othervm ExitFinalizersAndJIT
*/ */
public class ExitFinalizersAndJIT { public class ExitFinalizersAndJIT {
......
...@@ -155,7 +155,7 @@ public class GenerifyStackTraces { ...@@ -155,7 +155,7 @@ public class GenerifyStackTraces {
printStack(t, stack); printStack(t, stack);
} }
int frame = stack.length - 1; 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])) { if (! stack[frame].getMethodName().equals(methodNames[i])) {
throw new RuntimeException("Expected " + methodNames[i] + throw new RuntimeException("Expected " + methodNames[i] +
" in frame " + frame + " but got " + " in frame " + frame + " but got " +
......
...@@ -159,7 +159,7 @@ public class StackTraces { ...@@ -159,7 +159,7 @@ public class StackTraces {
printStack(t, stack); printStack(t, stack);
} }
int frame = stack.length - 1; 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])) { if (! stack[frame].getMethodName().equals(methodNames[i])) {
throw new RuntimeException("Expected " + methodNames[i] + throw new RuntimeException("Expected " + methodNames[i] +
" in frame " + frame + " but got " + " in frame " + frame + " but got " +
......
...@@ -118,9 +118,21 @@ class Chain { ...@@ -118,9 +118,21 @@ class Chain {
} }
class Slave {} class Slave {}
class LeftHand extends ClassLoader {} class LeftHand extends ClassLoader {
class RightHand extends ClassLoader {} public LeftHand() {
super(LeftHand.class.getClassLoader());
}
}
class RightHand extends ClassLoader {
public RightHand() {
super(RightHand.class.getClassLoader());
}
}
class Body {} class Body {}
class LoaderForTwoInstances extends ClassLoader {} class LoaderForTwoInstances extends ClassLoader {
public LoaderForTwoInstances() {
super(LoaderForTwoInstances.class.getClassLoader());
}
}
class TheSameClass {} class TheSameClass {}
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* @test * @test
* @bug 5024531 * @bug 5024531
* @summary Basic Test for ManagementFactory.newPlatformMXBean(). * @summary Basic Test for ManagementFactory.newPlatformMXBean().
* @run main/othervm MXBeanProxyTest
* @author Mandy Chung * @author Mandy Chung
*/ */
import javax.management.*; import javax.management.*;
......
...@@ -41,9 +41,9 @@ import javax.management.openmbean.CompositeData; ...@@ -41,9 +41,9 @@ import javax.management.openmbean.CompositeData;
public class CollectionUsageThreshold { public class CollectionUsageThreshold {
private static MemoryMXBean mm = ManagementFactory.getMemoryMXBean(); private static MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
private static List pools = ManagementFactory.getMemoryPoolMXBeans(); private static List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
private static List managers = ManagementFactory.getMemoryManagerMXBeans(); private static List<MemoryManagerMXBean> managers = ManagementFactory.getMemoryManagerMXBeans();
private static Map result = new HashMap(); private static Map<String, PoolRecord> result = new HashMap<>();
private static boolean trace = false; private static boolean trace = false;
private static boolean testFailed = false; private static boolean testFailed = false;
private static final int EXPECTED_NUM_POOLS = 2; private static final int EXPECTED_NUM_POOLS = 2;
...@@ -119,8 +119,7 @@ public class CollectionUsageThreshold { ...@@ -119,8 +119,7 @@ public class CollectionUsageThreshold {
} }
// Find the Old generation which supports low memory detection // Find the Old generation which supports low memory detection
for (ListIterator iter = pools.listIterator(); iter.hasNext(); ) { for (MemoryPoolMXBean p : pools) {
MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
MemoryUsage u = p.getUsage(); MemoryUsage u = p.getUsage();
if (p.isUsageThresholdSupported() && p.isCollectionUsageThresholdSupported()) { if (p.isUsageThresholdSupported() && p.isCollectionUsageThresholdSupported()) {
PoolRecord pr = new PoolRecord(p); PoolRecord pr = new PoolRecord(p);
...@@ -134,25 +133,30 @@ public class CollectionUsageThreshold { ...@@ -134,25 +133,30 @@ public class CollectionUsageThreshold {
throw new RuntimeException("Unexpected number of selected pools"); throw new RuntimeException("Unexpected number of selected pools");
} }
checker = new Checker("Checker thread"); try {
checker.setDaemon(true); checker = new Checker("Checker thread");
checker.start(); checker.setDaemon(true);
checker.start();
for (Iterator iter = result.values().iterator(); iter.hasNext();) { for (PoolRecord pr : result.values()) {
PoolRecord pr = (PoolRecord) iter.next(); pr.getPool().setCollectionUsageThreshold(THRESHOLD);
pr.getPool().setCollectionUsageThreshold(THRESHOLD); System.out.println("Collection usage threshold of " +
System.out.println("Collection usage threshold of " + pr.getPool().getName() + " set to " + THRESHOLD);
pr.getPool().getName() + " set to " + THRESHOLD); }
}
SensorListener listener = new SensorListener(); SensorListener listener = new SensorListener();
NotificationEmitter emitter = (NotificationEmitter) mm; NotificationEmitter emitter = (NotificationEmitter) mm;
emitter.addNotificationListener(listener, null, null); emitter.addNotificationListener(listener, null, null);
mm.setVerbose(true); for (int i = 0; i < NUM_GCS; i++) {
for (int i = 0; i < NUM_GCS; i++) { invokeGC();
invokeGC(); checker.waitForCheckResult();
checker.waitForCheckResult(); }
} finally {
// restore the default
for (PoolRecord pr : result.values()) {
pr.getPool().setCollectionUsageThreshold(0);
}
} }
if (testFailed) if (testFailed)
...@@ -168,8 +172,7 @@ public class CollectionUsageThreshold { ...@@ -168,8 +172,7 @@ public class CollectionUsageThreshold {
mm.gc(); mm.gc();
if (trace) { if (trace) {
for (Iterator iter = result.values().iterator(); iter.hasNext();) { for (PoolRecord pr : result.values()) {
PoolRecord pr = (PoolRecord) iter.next();
System.out.println("Usage after GC for: " + pr.getPool().getName()); System.out.println("Usage after GC for: " + pr.getPool().getName());
MemoryUtil.printMemoryUsage(pr.getPool().getUsage()); MemoryUtil.printMemoryUsage(pr.getPool().getUsage());
} }
...@@ -200,8 +203,7 @@ public class CollectionUsageThreshold { ...@@ -200,8 +203,7 @@ public class CollectionUsageThreshold {
} }
} }
private void checkResult() { private void checkResult() {
for (Iterator iter = result.values().iterator(); iter.hasNext();) { for (PoolRecord pr : result.values()) {
PoolRecord pr = (PoolRecord) iter.next();
if (pr.getListenerInvokedCount() != numGCs) { if (pr.getListenerInvokedCount() != numGCs) {
throw new RuntimeException("Listeners invoked count = " + throw new RuntimeException("Listeners invoked count = " +
pr.getListenerInvokedCount() + " expected to be " + pr.getListenerInvokedCount() + " expected to be " +
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* @author Mandy Chung * @author Mandy Chung
* *
* @build LowMemoryTest MemoryUtil * @build LowMemoryTest MemoryUtil
* @run main/timeout=600 LowMemoryTest * @run main/othervm/timeout=600 LowMemoryTest
*/ */
import java.lang.management.*; import java.lang.management.*;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* @author Mandy Chung * @author Mandy Chung
* *
* @build MemoryManagement MemoryUtil * @build MemoryManagement MemoryUtil
* @run main/timeout=600 MemoryManagement * @run main/othervm/timeout=600 MemoryManagement
*/ */
import java.lang.management.*; import java.lang.management.*;
......
...@@ -62,9 +62,21 @@ public class Pending { ...@@ -62,9 +62,21 @@ public class Pending {
trace = true; trace = true;
} }
// Turn on verbose:gc to track GC try {
mbean.setVerbose(true); 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 // Clean the memory and remove all objects that are pending
// finalization // finalization
System.gc(); System.gc();
...@@ -130,7 +142,6 @@ public class Pending { ...@@ -130,7 +142,6 @@ public class Pending {
+ " end = " + snapshot); + " end = " + snapshot);
} }
System.out.println("Test passed.");
} }
private static void checkFinalizerCount(int expectedTotal, int curFinalized) private static void checkFinalizerCount(int expectedTotal, int curFinalized)
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* @author Mandy Chung * @author Mandy Chung
* *
* @build ResetPeakMemoryUsage MemoryUtil * @build ResetPeakMemoryUsage MemoryUtil
* @run main ResetPeakMemoryUsage * @run main/othervm ResetPeakMemoryUsage
*/ */
import java.lang.management.*; import java.lang.management.*;
......
...@@ -37,11 +37,23 @@ import java.util.*; ...@@ -37,11 +37,23 @@ import java.util.*;
public class ThresholdTest { public class ThresholdTest {
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans(); List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean p : pools) { try {
// verify if isUsageThresholdExceeded() returns correct value for (MemoryPoolMXBean p : pools) {
checkUsageThreshold(p); // verify if isUsageThresholdExceeded() returns correct value
// verify if isCollectionUsageThresholdExceeded() returns correct value checkUsageThreshold(p);
checkCollectionUsageThreshold(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."); System.out.println("Test passed.");
......
...@@ -37,13 +37,18 @@ public class UpTime { ...@@ -37,13 +37,18 @@ public class UpTime {
= ManagementFactory.getRuntimeMXBean(); = ManagementFactory.getRuntimeMXBean();
public static void main(String argv[]) throws Exception { public static void main(String argv[]) throws Exception {
long jvmStartTime = metrics.getStartTime();
long systemStartOuter = System.currentTimeMillis(); long systemStartOuter = System.currentTimeMillis();
long metricsStart = metrics.getUptime(); long metricsStart = metrics.getUptime();
long systemStartInner = System.currentTimeMillis(); 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 // If uptime is more than 30 minutes then it looks like a bug in
// the method // the method
if (metricsStart > TIMEOUT * 60 * 1000) if (testUptime > TIMEOUT * 60 * 1000)
throw new RuntimeException("Uptime of the JVM is more than 30 " throw new RuntimeException("Uptime of the JVM is more than 30 "
+ "minutes (" + "minutes ("
+ (metricsStart / 60 / 1000) + (metricsStart / 60 / 1000)
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* @author Alexei Guibadoulline and Mandy Chung * @author Alexei Guibadoulline and Mandy Chung
* *
* @run build Barrier * @run build Barrier
* @run main AllThreadIds * @run main/othervm AllThreadIds
*/ */
import java.lang.management.*; import java.lang.management.*;
...@@ -70,6 +70,12 @@ public class AllThreadIds { ...@@ -70,6 +70,12 @@ public class AllThreadIds {
} }
} }
private static void fail(String msg) {
trace = true;
printThreadList();
throw new RuntimeException(msg);
}
private static void checkThreadCount(int numNewThreads, private static void checkThreadCount(int numNewThreads,
int numTerminatedThreads) int numTerminatedThreads)
throws Exception { throws Exception {
...@@ -82,27 +88,27 @@ public class AllThreadIds { ...@@ -82,27 +88,27 @@ public class AllThreadIds {
if ((curLiveThreadCount - prevLiveThreadCount) != if ((curLiveThreadCount - prevLiveThreadCount) !=
(numNewThreads - numTerminatedThreads)) { (numNewThreads - numTerminatedThreads)) {
throw new RuntimeException("Unexpected number of live threads: " + fail("Unexpected number of live threads: " +
" Prev Total = " + prevTotalThreadCount + " Prev live = " + prevLiveThreadCount +
" Current Total = " + curTotalThreadCount + " Current live = " + curLiveThreadCount +
" Threads added = " + numNewThreads + " Threads added = " + numNewThreads +
" Threads terminated = " + numTerminatedThreads); " Threads terminated = " + numTerminatedThreads);
} }
if (curPeakThreadCount - prevPeakThreadCount != numNewThreads) { if (curPeakThreadCount - prevPeakThreadCount != numNewThreads) {
throw new RuntimeException("Unexpected number of peak threads: " + fail("Unexpected number of peak threads: " +
" Prev Total = " + prevTotalThreadCount + " Prev peak = " + prevPeakThreadCount +
" Current Total = " + curTotalThreadCount + " Current peak = " + curPeakThreadCount +
" Threads added = " + numNewThreads); " Threads added = " + numNewThreads);
} }
if (curTotalThreadCount - prevTotalThreadCount != numNewThreads) { if (curTotalThreadCount - prevTotalThreadCount != numNewThreads) {
throw new RuntimeException("Unexpected number of total threads: " + fail("Unexpected number of total threads: " +
" Prev Total = " + prevTotalThreadCount + " Prev Total = " + prevTotalThreadCount +
" Current Total = " + curTotalThreadCount + " Current Total = " + curTotalThreadCount +
" Threads added = " + numNewThreads); " Threads added = " + numNewThreads);
} }
long[] list = mbean.getAllThreadIds(); long[] list = mbean.getAllThreadIds();
if (list.length != curLiveThreadCount) { if (list.length != curLiveThreadCount) {
throw new RuntimeException("Array length returned by " + fail("Array length returned by " +
"getAllThreadIds() = " + list.length + "getAllThreadIds() = " + list.length +
" not matched count = " + curLiveThreadCount); " not matched count = " + curLiveThreadCount);
} }
......
...@@ -36,8 +36,18 @@ public class DisableTest { ...@@ -36,8 +36,18 @@ public class DisableTest {
private static ThreadMXBean tm = ManagementFactory.getThreadMXBean(); private static ThreadMXBean tm = ManagementFactory.getThreadMXBean();
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
testThreadContentionMonitoring(); try {
testThreadCpuMonitoring(); testThreadContentionMonitoring();
testThreadCpuMonitoring();
} finally {
// restore the default
if (tm.isThreadContentionMonitoringSupported()) {
tm.setThreadContentionMonitoringEnabled(false);
}
if (tm.isThreadCpuTimeSupported()) {
tm.setThreadCpuTimeEnabled(false);
}
}
System.out.println("Test passed."); System.out.println("Test passed.");
} }
......
...@@ -119,8 +119,19 @@ public class EnableTest { ...@@ -119,8 +119,19 @@ public class EnableTest {
} }
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
testThreadContentionMonitoring(); try {
testThreadCpuTime(); testThreadContentionMonitoring();
testThreadCpuTime();
} finally {
// restore the default
if (tm.isThreadContentionMonitoringSupported()) {
tm.setThreadContentionMonitoringEnabled(false);
}
if (tm.isThreadCpuTimeSupported()) {
tm.setThreadCpuTimeEnabled(false);
}
}
System.out.println("Test passed."); System.out.println("Test passed.");
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* @build MonitorDeadlock * @build MonitorDeadlock
* @build SynchronizerDeadlock * @build SynchronizerDeadlock
* @build ThreadDump * @build ThreadDump
* @run main FindDeadlocks * @run main/othervm FindDeadlocks
*/ */
import java.lang.management.*; import java.lang.management.*;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* @build MonitorDeadlock * @build MonitorDeadlock
* @build ThreadDump * @build ThreadDump
* @run main FindMonitorDeadlock * @run main/othervm FindMonitorDeadlock
*/ */
import java.lang.management.*; import java.lang.management.*;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* @author Mandy Chung * @author Mandy Chung
* *
* @build ThreadExecutionSynchronizer * @build ThreadExecutionSynchronizer
* @run main Locks * @run main/othervm Locks
*/ */
import java.lang.management.*; import java.lang.management.*;
......
...@@ -71,8 +71,8 @@ public class Boxing { ...@@ -71,8 +71,8 @@ public class Boxing {
Random random = new Random(42); // ensure consistent test domain Random random = new Random(42); // ensure consistent test domain
Test proxy = (Test) Proxy.newProxyInstance( Test proxy = (Test) Proxy.newProxyInstance(
ClassLoader.getSystemClassLoader(), Test.class.getClassLoader(),
new Class[] { Test.class }, new Class<?>[] { Test.class },
new TestHandler()); new TestHandler());
for (int rep = 0; rep < REPS; rep++) { for (int rep = 0; rep < REPS; rep++) {
......
...@@ -54,16 +54,16 @@ public class ClassRestrictions { ...@@ -54,16 +54,16 @@ public class ClassRestrictions {
"\nTest of restrictions on parameters to Proxy.getProxyClass\n"); "\nTest of restrictions on parameters to Proxy.getProxyClass\n");
try { try {
ClassLoader loader = ClassLoader.getSystemClassLoader(); ClassLoader loader = ClassRestrictions.class.getClassLoader();
Class[] interfaces; Class<?>[] interfaces;
Class proxyClass; Class<?> proxyClass;
/* /*
* All of the Class objects in the interfaces array must represent * All of the Class objects in the interfaces array must represent
* interfaces, not classes or primitive types. * interfaces, not classes or primitive types.
*/ */
try { try {
interfaces = new Class[] { Object.class }; interfaces = new Class<?>[] { Object.class };
proxyClass = Proxy.getProxyClass(loader, interfaces); proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException( throw new RuntimeException(
"proxy class created with java.lang.Object as interface"); "proxy class created with java.lang.Object as interface");
...@@ -73,7 +73,7 @@ public class ClassRestrictions { ...@@ -73,7 +73,7 @@ public class ClassRestrictions {
// assume exception is for intended failure // assume exception is for intended failure
} }
try { try {
interfaces = new Class[] { Integer.TYPE }; interfaces = new Class<?>[] { Integer.TYPE };
proxyClass = Proxy.getProxyClass(loader, interfaces); proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException( throw new RuntimeException(
"proxy class created with int.class as interface"); "proxy class created with int.class as interface");
...@@ -88,7 +88,7 @@ public class ClassRestrictions { ...@@ -88,7 +88,7 @@ public class ClassRestrictions {
* Class objects. * Class objects.
*/ */
try { try {
interfaces = new Class[] { Bar.class, Bar.class }; interfaces = new Class<?>[] { Bar.class, Bar.class };
proxyClass = Proxy.getProxyClass(loader, interfaces); proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException( throw new RuntimeException(
"proxy class created with repeated interfaces"); "proxy class created with repeated interfaces");
...@@ -107,7 +107,7 @@ public class ClassRestrictions { ...@@ -107,7 +107,7 @@ public class ClassRestrictions {
Class altBarClass; Class altBarClass;
altBarClass = Class.forName(Bar.class.getName(), false, altLoader); altBarClass = Class.forName(Bar.class.getName(), false, altLoader);
try { try {
interfaces = new Class[] { altBarClass }; interfaces = new Class<?>[] { altBarClass };
proxyClass = Proxy.getProxyClass(loader, interfaces); proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException( throw new RuntimeException(
"proxy class created with interface " + "proxy class created with interface " +
...@@ -121,8 +121,8 @@ public class ClassRestrictions { ...@@ -121,8 +121,8 @@ public class ClassRestrictions {
/* /*
* All non-public interfaces must be in the same package. * All non-public interfaces must be in the same package.
*/ */
Class nonPublic1 = Bashful.class; Class<?> nonPublic1 = Bashful.class;
Class nonPublic2 = null; Class<?> nonPublic2 = null;
String[] nonPublicInterfaces = new String[] { String[] nonPublicInterfaces = new String[] {
"java.awt.Conditional", "java.awt.Conditional",
"java.util.zip.ZipConstants", "java.util.zip.ZipConstants",
...@@ -147,7 +147,7 @@ public class ClassRestrictions { ...@@ -147,7 +147,7 @@ public class ClassRestrictions {
"no second non-public interface found for test"); "no second non-public interface found for test");
} }
try { try {
interfaces = new Class[] { nonPublic1, nonPublic2 }; interfaces = new Class<?>[] { nonPublic1, nonPublic2 };
proxyClass = Proxy.getProxyClass(loader, interfaces); proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException( throw new RuntimeException(
"proxy class created with two non-public interfaces " + "proxy class created with two non-public interfaces " +
...@@ -163,7 +163,7 @@ public class ClassRestrictions { ...@@ -163,7 +163,7 @@ public class ClassRestrictions {
* parameter signature but different return type. * parameter signature but different return type.
*/ */
try { try {
interfaces = new Class[] { Bar.class, Baz.class }; interfaces = new Class<?>[] { Bar.class, Baz.class };
proxyClass = Proxy.getProxyClass(loader, interfaces); proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException( throw new RuntimeException(
"proxy class created with conflicting methods"); "proxy class created with conflicting methods");
......
...@@ -42,7 +42,7 @@ public class Test { ...@@ -42,7 +42,7 @@ public class Test {
// additional test cases may be added to both of these lists: // additional test cases may be added to both of these lists:
private static final Class[][] GOOD = { private static final Class<?>[][] GOOD = {
{ Collection.class }, { Collection.class },
{ Iterable.class, Collection.class }, { Iterable.class, Collection.class },
{ Iterable.class, Collection.class, List.class }, { Iterable.class, Collection.class, List.class },
...@@ -51,7 +51,7 @@ public class Test { ...@@ -51,7 +51,7 @@ public class Test {
GetArray.class } GetArray.class }
}; };
private static final Class[][] BAD = { private static final Class<?>[][] BAD = {
{ Runnable.class, PrivilegedAction.class }, { Runnable.class, PrivilegedAction.class },
{ GetSerializable.class, GetCloneable.class }, { GetSerializable.class, GetCloneable.class },
{ GetObject.class, GetSerializable.class, GetCloneable.class } { GetObject.class, GetSerializable.class, GetCloneable.class }
...@@ -60,12 +60,12 @@ public class Test { ...@@ -60,12 +60,12 @@ public class Test {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 4838310\n"); System.err.println("\nRegression test for bug 4838310\n");
ClassLoader loader = ClassLoader.getSystemClassLoader(); ClassLoader loader = Test.class.getClassLoader();
System.err.println("Testing GOOD combinations:"); System.err.println("Testing GOOD combinations:");
for (int i = 0; i < GOOD.length; i++) { for (int i = 0; i < GOOD.length; i++) {
Class[] interfaces = GOOD[i]; Class<?>[] interfaces = GOOD[i];
System.err.println(Arrays.asList(interfaces)); System.err.println(Arrays.asList(interfaces));
Proxy.getProxyClass(loader, interfaces); Proxy.getProxyClass(loader, interfaces);
System.err.println("--- OK."); System.err.println("--- OK.");
...@@ -74,7 +74,7 @@ public class Test { ...@@ -74,7 +74,7 @@ public class Test {
System.err.println("Testing BAD combinations:"); System.err.println("Testing BAD combinations:");
for (int i = 0; i < BAD.length; i++) { for (int i = 0; i < BAD.length; i++) {
Class[] interfaces = BAD[i]; Class<?>[] interfaces = BAD[i];
System.err.println(Arrays.asList(interfaces)); System.err.println(Arrays.asList(interfaces));
try { try {
Proxy.getProxyClass(loader, interfaces); Proxy.getProxyClass(loader, interfaces);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册