author | serb |
Fri, 16 Feb 2018 12:24:38 -0800 | |
changeset 49090 | 82c1fe23c469 |
parent 48278 | f3860ee5c026 |
permissions | -rw-r--r-- |
48278 | 1 |
/* |
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
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 |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
import java.awt.*; |
|
25 |
import java.util.concurrent.CountDownLatch; |
|
26 |
import java.util.concurrent.TimeUnit; |
|
27 |
||
28 |
/** |
|
29 |
* @test |
|
49090
82c1fe23c469
8196196: Headful tests should not be run in headless mode
serb
parents:
48278
diff
changeset
|
30 |
* @key headful |
48278 | 31 |
* @bug 8177758 |
32 |
* @requires os.family == "windows" |
|
33 |
* @summary Regression in java.awt.FileDialog |
|
34 |
* @run main FileDialogLeakTest |
|
35 |
*/ |
|
36 |
||
37 |
public class FileDialogLeakTest { |
|
38 |
static CountDownLatch latch = new CountDownLatch(3); |
|
39 |
static boolean passed; |
|
40 |
||
41 |
public static void main(String[] args) throws Exception { |
|
42 |
test(); |
|
43 |
System.gc(); |
|
44 |
System.runFinalization(); |
|
45 |
latch.await(1, TimeUnit.SECONDS); |
|
46 |
if (!passed) { |
|
47 |
throw new RuntimeException("Test failed."); |
|
48 |
} |
|
49 |
} |
|
50 |
||
51 |
private static void test() throws Exception { |
|
52 |
FileDialog fd = new FileDialog((Frame) null) { |
|
53 |
@Override |
|
54 |
protected void finalize() throws Throwable { |
|
55 |
System.out.println("Finalize"); |
|
56 |
super.finalize(); |
|
57 |
passed = true; |
|
58 |
latch.countDown(); |
|
59 |
} |
|
60 |
}; |
|
61 |
||
62 |
new Thread(() -> { |
|
63 |
latch.countDown(); |
|
64 |
fd.setVisible(true); |
|
65 |
latch.countDown(); |
|
66 |
}).start(); |
|
67 |
latch.await(1, TimeUnit.SECONDS); |
|
68 |
fd.dispose(); |
|
69 |
latch.await(1, TimeUnit.SECONDS); |
|
70 |
} |
|
71 |
||
72 |
} |
|
73 |