test/java/io/Serializable/resolveClass/deserializeButton/Foo.java

Print this page
rev 5550 : 7162111: TEST_BUG: change tests run in headless mode [macosx] (open)
Summary: In problem tests detection of AWT headless mode was introduced or AWT dependence was removed.
Reviewed-by: alanb

@@ -24,37 +24,36 @@
 /*
  * @bug 4413434
  * @summary Verify that class loaded outside of application class loader is
  *          correctly resolved during deserialization when read in by custom
  *          readObject() method of a bootstrap class (in this case,
- *          java.awt.Button).
+ *          java.util.Vector).
  */
 
-import java.awt.Button;
-import java.awt.event.MouseAdapter;
 import java.io.*;
+import java.util.Vector;
 
 public class Foo implements Runnable {
 
-    static class Adapter extends MouseAdapter implements Serializable {}
+    static class TestElement extends Object implements Serializable {}
 
     public void run() {
         try {
-            Button button = new Button();
-            button.addMouseListener(new Adapter());
+            Vector<TestElement> container = new Vector<TestElement>();
+            container.add(new TestElement());
 
             // iterate to trigger java.lang.reflect code generation
             for (int i = 0; i < 100; i++) {
                 ByteArrayOutputStream bout = new ByteArrayOutputStream();
                 ObjectOutputStream oout = new ObjectOutputStream(bout);
-                oout.writeObject(button);
+                oout.writeObject(container);
                 oout.close();
                 ObjectInputStream oin = new ObjectInputStream(
                     new ByteArrayInputStream(bout.toByteArray()));
                 oin.readObject();
             }
         } catch (Exception ex) {
             throw new Error(
-                "Error occured while (de)serializing Button: " + ex);
+                "Error occured while (de)serializing container: ", ex);
         }
     }
 }