changeset 6283:a02212de8db6

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
author uta
date Mon, 17 Dec 2012 14:34:37 +0400
parents f959e0cc8766
children 4a21f818ebb1
files test/java/io/Serializable/resolveProxyClass/NonPublicInterface.java test/java/lang/Throwable/LegacyChainedExceptionSerialization.java test/java/lang/management/CompilationMXBean/Basic.java test/java/lang/reflect/Generics/Probe.java test/java/lang/reflect/Proxy/ClassRestrictions.java test/java/util/Collections/EmptyIterator.java test/java/util/logging/LoggingDeadlock4.java test/sun/tools/jrunscript/common.sh
diffstat 8 files changed, 54 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/io/Serializable/resolveProxyClass/NonPublicInterface.java	Sun Dec 16 22:09:28 2012 -0800
+++ b/test/java/io/Serializable/resolveProxyClass/NonPublicInterface.java	Mon Dec 17 14:34:37 2012 +0400
@@ -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 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()));
--- a/test/java/lang/Throwable/LegacyChainedExceptionSerialization.java	Sun Dec 16 22:09:28 2012 -0800
+++ b/test/java/lang/Throwable/LegacyChainedExceptionSerialization.java	Mon Dec 17 14:34:37 2012 +0400
@@ -25,7 +25,7 @@
 
 /**
  * @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 @@
         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 {
--- a/test/java/lang/management/CompilationMXBean/Basic.java	Sun Dec 16 22:09:28 2012 -0800
+++ b/test/java/lang/management/CompilationMXBean/Basic.java	Mon Dec 17 14:34:37 2012 +0400
@@ -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 @@
 
         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();
--- a/test/java/lang/reflect/Generics/Probe.java	Sun Dec 16 22:09:28 2012 -0800
+++ b/test/java/lang/reflect/Generics/Probe.java	Mon Dec 17 14:34:37 2012 +0400
@@ -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 @@
           "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);
--- a/test/java/lang/reflect/Proxy/ClassRestrictions.java	Sun Dec 16 22:09:28 2012 -0800
+++ b/test/java/lang/reflect/Proxy/ClassRestrictions.java	Mon Dec 17 14:34:37 2012 +0400
@@ -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 @@
         void foo();
     }
 
+    public static final String nonPublicIntrfaceName = "java.util.zip.ZipConstants";
+
     public static void main(String[] args) {
 
         System.err.println(
@@ -65,7 +68,7 @@
             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 @@
             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 @@
             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 @@
             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 @@
              * 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 @@
             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 @@
              */
             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);
         }
     }
 }
--- a/test/java/util/Collections/EmptyIterator.java	Sun Dec 16 22:09:28 2012 -0800
+++ b/test/java/util/Collections/EmptyIterator.java	Mon Dec 17 14:34:37 2012 +0400
@@ -23,12 +23,12 @@
 
 /*
  * @test
- * @bug 5017904 6356890
+ * @bug 5017904 6356890 8004928
  * @summary Test empty iterators, enumerations, and collections
  */
 
+import static java.util.Collections.*;
 import java.util.*;
-import static java.util.Collections.*;
 
 public class EmptyIterator {
 
@@ -45,10 +45,13 @@
         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()
--- a/test/java/util/logging/LoggingDeadlock4.java	Sun Dec 16 22:09:28 2012 -0800
+++ b/test/java/util/logging/LoggingDeadlock4.java	Mon Dec 17 14:34:37 2012 +0400
@@ -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 @@
     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
--- a/test/sun/tools/jrunscript/common.sh	Sun Dec 16 22:09:28 2012 -0800
+++ b/test/sun/tools/jrunscript/common.sh	Mon Dec 17 14:34:37 2012 +0400
@@ -63,8 +63,4 @@
     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
 }