19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 |
|
25 /* |
24 /* |
26 test |
25 @test |
27 @bug 4051487 4145670 8062021 |
26 @key headful |
|
27 @bug 4051487 4145670 |
28 @summary Tests that disposing of an empty Frame or a Frame with a MenuBar |
28 @summary Tests that disposing of an empty Frame or a Frame with a MenuBar |
29 while it is being created does not crash the VM. |
29 while it is being created does not crash the VM. |
30 @author dpm area=Threads |
30 @run main/timeout=7200 DisposeStressTest |
31 @run applet/timeout=7200 DisposeStressTest.html |
|
32 */ |
31 */ |
33 |
32 |
34 // Note there is no @ in front of test above. This is so that the |
33 import java.awt.Frame; |
35 // harness will not mistake this file as a test file. It should |
34 import java.awt.Menu; |
36 // only see the html file as a test file. (the harness runs all |
35 import java.awt.MenuBar; |
37 // valid test files, so it would run this test twice if this file |
36 import java.awt.MenuItem; |
38 // were valid as well as the html file.) |
|
39 // Also, note the area= after Your Name in the author tag. Here, you |
|
40 // should put which functional area the test falls in. See the |
|
41 // AWT-core home page -> test areas and/or -> AWT team for a list of |
|
42 // areas. |
|
43 // Note also the 'DisposeStressTest.html' in the run tag. This should |
|
44 // be changed to the name of the test. |
|
45 |
37 |
|
38 public class DisposeStressTest { |
46 |
39 |
47 /** |
40 public static void main(final String[] args) { |
48 * DisposeStressTest.java |
|
49 * |
|
50 * summary: |
|
51 */ |
|
52 |
|
53 import java.applet.Applet; |
|
54 import java.awt.*; |
|
55 |
|
56 |
|
57 //Automated tests should run as applet tests if possible because they |
|
58 // get their environments cleaned up, including AWT threads, any |
|
59 // test created threads, and any system resources used by the test |
|
60 // such as file descriptors. (This is normally not a problem as |
|
61 // main tests usually run in a separate VM, however on some platforms |
|
62 // such as the Mac, separate VMs are not possible and non-applet |
|
63 // tests will cause problems). Also, you don't have to worry about |
|
64 // synchronisation stuff in Applet tests they way you do in main |
|
65 // tests... |
|
66 |
|
67 |
|
68 public class DisposeStressTest extends Applet |
|
69 { |
|
70 //Declare things used in the test, like buttons and labels here |
|
71 |
|
72 public void init() |
|
73 { |
|
74 //Create instructions for the user here, as well as set up |
|
75 // the environment -- set the layout manager, add buttons, |
|
76 // etc. |
|
77 |
|
78 this.setLayout (new BorderLayout ()); |
|
79 |
|
80 |
|
81 }//End init() |
|
82 |
|
83 public void start () |
|
84 { |
|
85 for (int i = 0; i < 1000; i++) { |
41 for (int i = 0; i < 1000; i++) { |
86 Frame f = new Frame(); |
42 Frame f = new Frame(); |
87 f.setBounds(10, 10, 10, 10); |
43 f.setBounds(10, 10, 10, 10); |
88 f.show(); |
44 f.show(); |
89 f.dispose(); |
45 f.dispose(); |