提交 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 @@
*/
/* @test
* @bug 4413817
* @bug 4413817 8004928
* @summary Verify that ObjectInputStream.resolveProxyClass can properly
* resolve a dynamic proxy class which implements a non-public
* interface not defined in the latest user defined class loader.
*/
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 {
......@@ -39,35 +42,19 @@ public class NonPublicInterface {
}
}
public static final String nonPublicIntrfaceName = "java.util.zip.ZipConstants";
public static void main(String[] args) throws Exception {
Class nonPublic = null;
String[] nonPublicInterfaces = new String[] {
"java.awt.Conditional",
"java.util.zip.ZipConstants",
"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");
Class<?> nonPublic = Class.forName(nonPublicIntrfaceName);
if (Modifier.isPublic(nonPublic.getModifiers())) {
throw new Error("Interface " + nonPublicIntrfaceName +
" is public and need to be changed!");
}
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
oout.writeObject(Proxy.newProxyInstance(nonPublic.getClassLoader(),
new Class[]{ nonPublic }, new Handler()));
new Class<?>[]{ nonPublic }, new Handler()));
oout.close();
ObjectInputStream oin = new ObjectInputStream(
new ByteArrayInputStream(bout.toByteArray()));
......
......@@ -25,7 +25,7 @@ import java.io.*;
/**
* @test
* @bug 4385429
* @bug 4385429 8004928
* @summary Certain legacy chained exceptions throw IllegalArgumentException
* upon deserialization if "causative exception" is null.
* @author Josh Bloch
......@@ -36,8 +36,7 @@ public class LegacyChainedExceptionSerialization {
new ExceptionInInitializerError(),
new java.lang.reflect.UndeclaredThrowableException(null),
new java.lang.reflect.InvocationTargetException(null),
new java.security.PrivilegedActionException(null),
new java.awt.print.PrinterIOException(null)
new java.security.PrivilegedActionException(null)
};
public static void main(String[] args) throws Exception {
......
......@@ -23,10 +23,10 @@
/*
* @test
* @bug 5011189
* @bug 5011189 8004928
* @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.*;
......@@ -65,8 +65,6 @@ public class Basic {
java.util.Locale.getAvailableLocales();
java.security.Security.getProviders();
java.awt.Toolkit.getDefaultToolkit();
javax.swing.UIManager.getInstalledLookAndFeels();
java.nio.channels.spi.SelectorProvider.provider();
time = mb.getTotalCompilationTime();
......
......@@ -23,7 +23,7 @@
/*
* @test
* @bug 5003916 6704655 6873951 6476261
* @bug 5003916 6704655 6873951 6476261 8004928
* @summary Testing parsing of signatures attributes of nested classes
* @author Joseph D. Darcy
*/
......@@ -52,8 +52,7 @@ import static java.util.Arrays.*;
"java.util.HashMap$ValueIterator",
"java.util.LinkedHashMap$EntryIterator",
"java.util.LinkedHashMap$KeyIterator",
"java.util.LinkedHashMap$ValueIterator",
"javax.swing.JComboBox$AccessibleJComboBox"})
"java.util.LinkedHashMap$ValueIterator"})
public class Probe {
public static void main (String... args) throws Throwable {
Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
......
......@@ -22,7 +22,7 @@
*/
/* @test
* @bug 4227192
* @bug 4227192 8004928
* @summary This is a test of the restrictions on the parameters that may
* be passed to the Proxy.getProxyClass method.
* @author Peter Jones
......@@ -31,6 +31,7 @@
* @run main ClassRestrictions
*/
import java.lang.reflect.Modifier;
import java.lang.reflect.Proxy;
import java.net.URLClassLoader;
......@@ -48,6 +49,8 @@ public class ClassRestrictions {
void foo();
}
public static final String nonPublicIntrfaceName = "java.util.zip.ZipConstants";
public static void main(String[] args) {
System.err.println(
......@@ -65,7 +68,7 @@ public class ClassRestrictions {
try {
interfaces = new Class<?>[] { Object.class };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
throw new Error(
"proxy class created with java.lang.Object as interface");
} catch (IllegalArgumentException e) {
e.printStackTrace();
......@@ -75,7 +78,7 @@ public class ClassRestrictions {
try {
interfaces = new Class<?>[] { Integer.TYPE };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
throw new Error(
"proxy class created with int.class as interface");
} catch (IllegalArgumentException e) {
e.printStackTrace();
......@@ -90,7 +93,7 @@ public class ClassRestrictions {
try {
interfaces = new Class<?>[] { Bar.class, Bar.class };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
throw new Error(
"proxy class created with repeated interfaces");
} catch (IllegalArgumentException e) {
e.printStackTrace();
......@@ -109,7 +112,7 @@ public class ClassRestrictions {
try {
interfaces = new Class<?>[] { altBarClass };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
throw new Error(
"proxy class created with interface " +
"not visible to class loader");
} catch (IllegalArgumentException e) {
......@@ -122,34 +125,16 @@ public class ClassRestrictions {
* All non-public interfaces must be in the same package.
*/
Class<?> nonPublic1 = Bashful.class;
Class<?> nonPublic2 = null;
String[] nonPublicInterfaces = new String[] {
"java.awt.Conditional",
"java.util.zip.ZipConstants",
"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 {
nonPublic2 = Class.forName(nonPublicInterfaces[i]);
break;
} catch (ClassNotFoundException e) {
}
}
if (nonPublic2 == null) {
throw new RuntimeException(
"no second non-public interface found for test");
Class<?> nonPublic2 = Class.forName(nonPublicIntrfaceName);
if (Modifier.isPublic(nonPublic2.getModifiers())) {
throw new Error(
"Interface " + nonPublicIntrfaceName +
" is public and need to be changed!");
}
try {
interfaces = new Class<?>[] { nonPublic1, nonPublic2 };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
throw new Error(
"proxy class created with two non-public interfaces " +
"in different packages");
} catch (IllegalArgumentException e) {
......@@ -165,7 +150,7 @@ public class ClassRestrictions {
try {
interfaces = new Class<?>[] { Bar.class, Baz.class };
proxyClass = Proxy.getProxyClass(loader, interfaces);
throw new RuntimeException(
throw new Error(
"proxy class created with conflicting methods");
} catch (IllegalArgumentException e) {
e.printStackTrace();
......@@ -178,10 +163,10 @@ public class ClassRestrictions {
*/
System.err.println("\nTEST PASSED");
} catch (Exception e) {
} catch (Throwable e) {
System.err.println("\nTEST FAILED:");
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
throw new Error("TEST FAILED: ", e);
}
}
}
......@@ -23,12 +23,12 @@
/*
* @test
* @bug 5017904 6356890
* @bug 5017904 6356890 8004928
* @summary Test empty iterators, enumerations, and collections
*/
import java.util.*;
import static java.util.Collections.*;
import java.util.*;
public class EmptyIterator {
......@@ -45,10 +45,13 @@ public class EmptyIterator {
testEmptyIterator(emptyTable.values().iterator());
testEmptyIterator(emptyTable.entrySet().iterator());
testEmptyEnumeration(javax.swing.tree.DefaultMutableTreeNode
.EMPTY_ENUMERATION);
testEmptyEnumeration(javax.swing.text.SimpleAttributeSet
.EMPTY.getAttributeNames());
final Enumeration<EmptyIterator> finalEmptyTyped =
Collections.emptyEnumeration();
testEmptyEnumeration(finalEmptyTyped);
final Enumeration finalEmptyAbstract =
Collections.emptyEnumeration();
testEmptyEnumeration(finalEmptyAbstract);
@SuppressWarnings("unchecked") Iterator<?> x =
new sun.tools.java.MethodSet()
......
......@@ -23,11 +23,11 @@
/*
* @test
* @bug 6977677
* @bug 6977677 8004928
* @summary Deadlock between LogManager.<clinit> and Logger.getLogger()
* @author Daniel D. Daugherty
* @build LoggingDeadlock4
* @run main/othervm/timeout=15 -Djava.awt.headless=true LoggingDeadlock4
* @compile -XDignore.symbol.file LoggingDeadlock4.java
* @run main/othervm/timeout=15 LoggingDeadlock4
*/
import java.util.concurrent.CountDownLatch;
......@@ -39,21 +39,16 @@ public class LoggingDeadlock4 {
private static CountDownLatch lmIsRunning = 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) {
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") {
public void run() {
// let main know LogManagerThread is running
......
......@@ -63,8 +63,4 @@ setup() {
JRUNSCRIPT="${TESTJAVA}/bin/jrunscript"
JAVAC="${TESTJAVA}/bin/javac"
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.
先完成此消息的编辑!
想要评论请 注册