提交 7ba91053 编写于 作者: U uta

8004928: TEST_BUG: Reduce dependence of CoreLib tests from the AWT subsystem

Summary: the tests were refactored to drop AWT dependence where it was possible.
Reviewed-by: alanb, mchung
上级 5eb82201
...@@ -22,14 +22,17 @@ ...@@ -22,14 +22,17 @@
*/ */
/* @test /* @test
* @bug 4413817 * @bug 4413817 8004928
* @summary Verify that ObjectInputStream.resolveProxyClass can properly * @summary Verify that ObjectInputStream.resolveProxyClass can properly
* resolve a dynamic proxy class which implements a non-public * resolve a dynamic proxy class which implements a non-public
* interface not defined in the latest user defined class loader. * interface not defined in the latest user defined class loader.
*/ */
import java.io.*; import java.io.*;
import java.lang.reflect.*; import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
public class NonPublicInterface { public class NonPublicInterface {
...@@ -39,35 +42,19 @@ public class NonPublicInterface { ...@@ -39,35 +42,19 @@ public class NonPublicInterface {
} }
} }
public static final String nonPublicIntrfaceName = "java.util.zip.ZipConstants";
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Class nonPublic = null; Class<?> nonPublic = Class.forName(nonPublicIntrfaceName);
String[] nonPublicInterfaces = new String[] { if (Modifier.isPublic(nonPublic.getModifiers())) {
"java.awt.Conditional", throw new Error("Interface " + nonPublicIntrfaceName +
"java.util.zip.ZipConstants", " is public and need to be changed!");
"javax.swing.GraphicsWrapper",
"javax.swing.JPopupMenu$Popup",
"javax.swing.JTable$Resizable2",
"javax.swing.JTable$Resizable3",
"javax.swing.ToolTipManager$Popup",
"sun.audio.Format",
"sun.audio.HaePlayable",
"sun.tools.agent.StepConstants",
};
for (int i = 0; i < nonPublicInterfaces.length; i++) {
try {
nonPublic = Class.forName(nonPublicInterfaces[i]);
break;
} catch (ClassNotFoundException ex) {
}
}
if (nonPublic == null) {
throw new Error("couldn't find system non-public interface");
} }
ByteArrayOutputStream bout = new ByteArrayOutputStream(); ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout); ObjectOutputStream oout = new ObjectOutputStream(bout);
oout.writeObject(Proxy.newProxyInstance(nonPublic.getClassLoader(), oout.writeObject(Proxy.newProxyInstance(nonPublic.getClassLoader(),
new Class[]{ nonPublic }, new Handler())); new Class<?>[]{ nonPublic }, new Handler()));
oout.close(); oout.close();
ObjectInputStream oin = new ObjectInputStream( ObjectInputStream oin = new ObjectInputStream(
new ByteArrayInputStream(bout.toByteArray())); new ByteArrayInputStream(bout.toByteArray()));
......
...@@ -25,7 +25,7 @@ import java.io.*; ...@@ -25,7 +25,7 @@ import java.io.*;
/** /**
* @test * @test
* @bug 4385429 * @bug 4385429 8004928
* @summary Certain legacy chained exceptions throw IllegalArgumentException * @summary Certain legacy chained exceptions throw IllegalArgumentException
* upon deserialization if "causative exception" is null. * upon deserialization if "causative exception" is null.
* @author Josh Bloch * @author Josh Bloch
...@@ -36,8 +36,7 @@ public class LegacyChainedExceptionSerialization { ...@@ -36,8 +36,7 @@ public class LegacyChainedExceptionSerialization {
new ExceptionInInitializerError(), new ExceptionInInitializerError(),
new java.lang.reflect.UndeclaredThrowableException(null), new java.lang.reflect.UndeclaredThrowableException(null),
new java.lang.reflect.InvocationTargetException(null), new java.lang.reflect.InvocationTargetException(null),
new java.security.PrivilegedActionException(null), new java.security.PrivilegedActionException(null)
new java.awt.print.PrinterIOException(null)
}; };
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
......
...@@ -23,10 +23,10 @@ ...@@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 5011189 * @bug 5011189 8004928
* @summary Unit test for java.lang.management.CompilationMXBean * @summary Unit test for java.lang.management.CompilationMXBean
* *
* @run main/othervm -Xcomp -Xbatch -Djava.awt.headless=true Basic * @run main/othervm -Xcomp -Xbatch Basic
*/ */
import java.lang.management.*; import java.lang.management.*;
...@@ -65,8 +65,6 @@ public class Basic { ...@@ -65,8 +65,6 @@ public class Basic {
java.util.Locale.getAvailableLocales(); java.util.Locale.getAvailableLocales();
java.security.Security.getProviders(); java.security.Security.getProviders();
java.awt.Toolkit.getDefaultToolkit();
javax.swing.UIManager.getInstalledLookAndFeels();
java.nio.channels.spi.SelectorProvider.provider(); java.nio.channels.spi.SelectorProvider.provider();
time = mb.getTotalCompilationTime(); time = mb.getTotalCompilationTime();
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 5003916 6704655 6873951 6476261 * @bug 5003916 6704655 6873951 6476261 8004928
* @summary Testing parsing of signatures attributes of nested classes * @summary Testing parsing of signatures attributes of nested classes
* @author Joseph D. Darcy * @author Joseph D. Darcy
*/ */
...@@ -52,8 +52,7 @@ import static java.util.Arrays.*; ...@@ -52,8 +52,7 @@ import static java.util.Arrays.*;
"java.util.HashMap$ValueIterator", "java.util.HashMap$ValueIterator",
"java.util.LinkedHashMap$EntryIterator", "java.util.LinkedHashMap$EntryIterator",
"java.util.LinkedHashMap$KeyIterator", "java.util.LinkedHashMap$KeyIterator",
"java.util.LinkedHashMap$ValueIterator", "java.util.LinkedHashMap$ValueIterator"})
"javax.swing.JComboBox$AccessibleJComboBox"})
public class Probe { public class Probe {
public static void main (String... args) throws Throwable { public static void main (String... args) throws Throwable {
Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class); Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
/* @test /* @test
* @bug 4227192 * @bug 4227192 8004928
* @summary This is a test of the restrictions on the parameters that may * @summary This is a test of the restrictions on the parameters that may
* be passed to the Proxy.getProxyClass method. * be passed to the Proxy.getProxyClass method.
* @author Peter Jones * @author Peter Jones
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
* @run main ClassRestrictions * @run main ClassRestrictions
*/ */
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.net.URLClassLoader; import java.net.URLClassLoader;
...@@ -48,6 +49,8 @@ public class ClassRestrictions { ...@@ -48,6 +49,8 @@ public class ClassRestrictions {
void foo(); void foo();
} }
public static final String nonPublicIntrfaceName = "java.util.zip.ZipConstants";
public static void main(String[] args) { public static void main(String[] args) {
System.err.println( System.err.println(
...@@ -65,7 +68,7 @@ public class ClassRestrictions { ...@@ -65,7 +68,7 @@ public class ClassRestrictions {
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 Error(
"proxy class created with java.lang.Object as interface"); "proxy class created with java.lang.Object as interface");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -75,7 +78,7 @@ public class ClassRestrictions { ...@@ -75,7 +78,7 @@ public class ClassRestrictions {
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 Error(
"proxy class created with int.class as interface"); "proxy class created with int.class as interface");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -90,7 +93,7 @@ public class ClassRestrictions { ...@@ -90,7 +93,7 @@ public class ClassRestrictions {
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 Error(
"proxy class created with repeated interfaces"); "proxy class created with repeated interfaces");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -109,7 +112,7 @@ public class ClassRestrictions { ...@@ -109,7 +112,7 @@ public class ClassRestrictions {
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 Error(
"proxy class created with interface " + "proxy class created with interface " +
"not visible to class loader"); "not visible to class loader");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
...@@ -122,34 +125,16 @@ public class ClassRestrictions { ...@@ -122,34 +125,16 @@ 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 = Class.forName(nonPublicIntrfaceName);
String[] nonPublicInterfaces = new String[] { if (Modifier.isPublic(nonPublic2.getModifiers())) {
"java.awt.Conditional", throw new Error(
"java.util.zip.ZipConstants", "Interface " + nonPublicIntrfaceName +
"javax.swing.GraphicsWrapper", " is public and need to be changed!");
"javax.swing.JPopupMenu$Popup",
"javax.swing.JTable$Resizable2",
"javax.swing.JTable$Resizable3",
"javax.swing.ToolTipManager$Popup",
"sun.audio.Format",
"sun.audio.HaePlayable",
"sun.tools.agent.StepConstants",
};
for (int i = 0; i < nonPublicInterfaces.length; i++) {
try {
nonPublic2 = Class.forName(nonPublicInterfaces[i]);
break;
} catch (ClassNotFoundException e) {
}
}
if (nonPublic2 == null) {
throw new RuntimeException(
"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 Error(
"proxy class created with two non-public interfaces " + "proxy class created with two non-public interfaces " +
"in different packages"); "in different packages");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
...@@ -165,7 +150,7 @@ public class ClassRestrictions { ...@@ -165,7 +150,7 @@ public class ClassRestrictions {
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 Error(
"proxy class created with conflicting methods"); "proxy class created with conflicting methods");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -178,10 +163,10 @@ public class ClassRestrictions { ...@@ -178,10 +163,10 @@ public class ClassRestrictions {
*/ */
System.err.println("\nTEST PASSED"); System.err.println("\nTEST PASSED");
} catch (Exception e) { } catch (Throwable e) {
System.err.println("\nTEST FAILED:"); System.err.println("\nTEST FAILED:");
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString()); throw new Error("TEST FAILED: ", e);
} }
} }
} }
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
/* /*
* @test * @test
* @bug 5017904 6356890 * @bug 5017904 6356890 8004928
* @summary Test empty iterators, enumerations, and collections * @summary Test empty iterators, enumerations, and collections
*/ */
import java.util.*;
import static java.util.Collections.*; import static java.util.Collections.*;
import java.util.*;
public class EmptyIterator { public class EmptyIterator {
...@@ -45,10 +45,13 @@ public class EmptyIterator { ...@@ -45,10 +45,13 @@ public class EmptyIterator {
testEmptyIterator(emptyTable.values().iterator()); testEmptyIterator(emptyTable.values().iterator());
testEmptyIterator(emptyTable.entrySet().iterator()); testEmptyIterator(emptyTable.entrySet().iterator());
testEmptyEnumeration(javax.swing.tree.DefaultMutableTreeNode final Enumeration<EmptyIterator> finalEmptyTyped =
.EMPTY_ENUMERATION); Collections.emptyEnumeration();
testEmptyEnumeration(javax.swing.text.SimpleAttributeSet testEmptyEnumeration(finalEmptyTyped);
.EMPTY.getAttributeNames());
final Enumeration finalEmptyAbstract =
Collections.emptyEnumeration();
testEmptyEnumeration(finalEmptyAbstract);
@SuppressWarnings("unchecked") Iterator<?> x = @SuppressWarnings("unchecked") Iterator<?> x =
new sun.tools.java.MethodSet() new sun.tools.java.MethodSet()
......
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
/* /*
* @test * @test
* @bug 6977677 * @bug 6977677 8004928
* @summary Deadlock between LogManager.<clinit> and Logger.getLogger() * @summary Deadlock between LogManager.<clinit> and Logger.getLogger()
* @author Daniel D. Daugherty * @author Daniel D. Daugherty
* @build LoggingDeadlock4 * @compile -XDignore.symbol.file LoggingDeadlock4.java
* @run main/othervm/timeout=15 -Djava.awt.headless=true LoggingDeadlock4 * @run main/othervm/timeout=15 LoggingDeadlock4
*/ */
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
...@@ -39,21 +39,16 @@ public class LoggingDeadlock4 { ...@@ -39,21 +39,16 @@ public class LoggingDeadlock4 {
private static CountDownLatch lmIsRunning = new CountDownLatch(1); private static CountDownLatch lmIsRunning = new CountDownLatch(1);
private static CountDownLatch logIsRunning = new CountDownLatch(1); private static CountDownLatch logIsRunning = new CountDownLatch(1);
// Create a sun.util.logging.PlatformLogger$JavaLogger object
// that has to be redirected when the LogManager class
// is initialized. This can cause a deadlock between
// LogManager.<clinit> and Logger.getLogger().
private static final sun.util.logging.PlatformLogger log =
sun.util.logging.PlatformLogger.getLogger("java.util.logging");
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("main: LoggingDeadlock4 is starting."); System.out.println("main: LoggingDeadlock4 is starting.");
// Loading the java.awt.Container class will create a
// sun.util.logging.PlatformLogger$JavaLogger object
// that has to be redirected when the LogManager class
// is initialized. This can cause a deadlock between
// LogManager.<clinit> and Logger.getLogger().
try {
Class.forName("java.awt.Container");
} catch (ClassNotFoundException cnfe) {
throw new RuntimeException("Test failed: could not load"
+ " java.awt.Container." + cnfe);
}
Thread lmThread = new Thread("LogManagerThread") { Thread lmThread = new Thread("LogManagerThread") {
public void run() { public void run() {
// let main know LogManagerThread is running // let main know LogManagerThread is running
......
...@@ -63,8 +63,4 @@ setup() { ...@@ -63,8 +63,4 @@ setup() {
JRUNSCRIPT="${TESTJAVA}/bin/jrunscript" JRUNSCRIPT="${TESTJAVA}/bin/jrunscript"
JAVAC="${TESTJAVA}/bin/javac" JAVAC="${TESTJAVA}/bin/javac"
JAVA="${TESTJAVA}/bin/java" JAVA="${TESTJAVA}/bin/java"
# needed to get full headless behavior on Mac
if [ "$OS" = "Darwin" ]; then
export AWT_TOOLKIT=XToolkit
fi
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册