< prev index next >

test/jdk/java/lang/Runtime/shutdown/Basic.java

Print this page

        

@@ -47,16 +47,17 @@
 public class Basic {
 
     static Runtime rt = Runtime.getRuntime();
     static PrintStream out = System.out;
 
+    // Expect that no finalizer is invoked at exit
     @DataProvider(name = "testcase")
     public Object[][] getTestCase() {
         return new Object[][] {
-            { "fallThrough", 0, "h1", "f1" },
-            { "exit0",       0, "h1", "f1" },
-            { "exit0NoHook", 0, "",   "f1" },
+            { "fallThrough", 0, "h1", "" },
+            { "exit0",       0, "h1", "" },
+            { "exit0NoHook", 0, "",   "" },
             { "exit1",       1, "h1", "" },
             { "exit1NoHook", 1, "",   "" },
             { "halt",        0, "",   "" },
             { "haltNoHook",  0, "",   "" },
             { "haltInHook",  0, "h1", "" },

@@ -110,59 +111,51 @@
     }
 
     public static void fallThrough() throws Exception {
         rt.addShutdownHook(new Hook("h1"));
         Fin f = new Fin("f1");
-        rt.runFinalizersOnExit(true);
     }
 
     public static void exit0() throws Exception {
         rt.addShutdownHook(new Hook("h1"));
         Fin f = new Fin("f1");
-        rt.runFinalizersOnExit(true);
         rt.exit(0);
     }
 
     public static void exit0NoHook() throws Exception {
         Fin f = new Fin("f1");
-        rt.runFinalizersOnExit(true);
         rt.exit(0);
     }
 
     /* Finalizer should not run */
     public static void exit1() throws Exception {
         rt.addShutdownHook(new Hook("h1"));
         Fin f = new Fin("f1");
-        rt.runFinalizersOnExit(true);
         rt.exit(1);
     }
 
     public static void exit1NoHook() throws Exception {
         Fin f = new Fin("f1");
-        rt.runFinalizersOnExit(true);
         rt.exit(1);
     }
 
     public static void halt() throws Exception {
         rt.addShutdownHook(new Hook("h1") {
             public void go() { rt.halt(1); }});
         Fin f = new Fin("f1") { public void go() { rt.halt(1); }};
-        rt.runFinalizersOnExit(true);
         rt.halt(0);
     }
 
     public static void haltNoHook() throws Exception {
         Fin f = new Fin("f1") { public void go() { rt.halt(1); }};
-        rt.runFinalizersOnExit(true);
         rt.halt(0);
     }
 
     public static void haltInHook() throws Exception {
         rt.addShutdownHook(new Hook("h1") {
             public void go() { rt.halt(0); }});
         Fin f = new Fin("f1");
-        rt.runFinalizersOnExit(true);
         rt.exit(1);
     }
 
     public static void addLate() throws Exception {
         rt.addShutdownHook(new Hook("h1") {

@@ -189,56 +182,13 @@
                 }
             }});
         rt.exit(1);
     }
 
-
-    /* The following two methods are provided for manual testing only.
-     * Neither test is suitable for being run from within the harness.
-     */
-
-    public static void awt() throws Exception {
-        final Frame f = new Frame();
-        final TextArea ta = new TextArea();
-        Fin fx = new Fin("f1");
-        rt.runFinalizersOnExit(true);
-        rt.addShutdownHook(new Hook("h1") {
-            public void go() {
-                ta.setText("Hooked!");
-                out.println("Hooked!");
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException x) { }
-                ta.append("\nSleep 1");
-                out.println("Sleep 1");
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException x) { }
-                ta.append("\nSleep 2");
-                out.println("Sleep 2");
-            }});
-        f.addWindowListener(new WindowAdapter() {
-            public void windowClosing(WindowEvent e) {
-                out.println("Closing...");
-                ta.setText("Closing...");
-                try {
-                    Thread.sleep(1000);
-                } catch (InterruptedException x) { }
-                f.dispose();
-                rt.exit(42);
-            }});
-        ta.setText("Terminate me!");
-        f.add(ta);
-        f.pack();
-        f.show();
-        Thread.sleep(10000);
-    }
-
     /* For INT, HUP, TERM */
     public static void stall() throws Exception {
         Fin f = new Fin("f1");
-        rt.runFinalizersOnExit(true);
         rt.addShutdownHook(new Hook("h1"));
         out.print("Type ^C now: ");
         out.flush();
         Thread.sleep(100000);
     }
< prev index next >