author | serb |
Sat, 10 Nov 2018 18:48:35 -0800 | |
changeset 52549 | 50de7d1f6b64 |
child 54238 | 371d29d4add5 |
permissions | -rw-r--r-- |
52549
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
1 |
/* |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
4 |
* |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
8 |
* |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
14 |
* |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
18 |
* |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
21 |
* questions. |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
22 |
*/ |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
23 |
|
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
24 |
import java.awt.Button; |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
25 |
import java.awt.Frame; |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
26 |
import java.util.concurrent.TimeUnit; |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
27 |
|
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
28 |
import sun.awt.SunToolkit; |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
29 |
|
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
30 |
/** |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
31 |
* @test |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
32 |
* @key headful |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
33 |
* @bug 8211435 |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
34 |
* @requires (os.family == "mac") |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
35 |
* @modules java.desktop/sun.awt |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
36 |
*/ |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
37 |
public final class NullActiveWindowOnFocusLost { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
38 |
|
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
39 |
private static volatile long endtime; |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
40 |
private static Throwable failed; |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
41 |
|
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
42 |
public static void main(final String[] args) throws Exception { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
43 |
// Will run the test no more than 30 seconds |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
44 |
endtime = System.nanoTime() + TimeUnit.SECONDS.toNanos(30); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
45 |
Thread.setDefaultUncaughtExceptionHandler((t, e) -> failed = e); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
46 |
|
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
47 |
final Thread[] threads = new Thread[20]; |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
48 |
for (int i = 0; i < threads.length; i++) { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
49 |
threads[i] = testThread(i); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
50 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
51 |
for (final Thread thread : threads) { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
52 |
thread.start(); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
53 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
54 |
for (final Thread thread : threads) { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
55 |
thread.join(); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
56 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
57 |
if (failed != null) { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
58 |
failed.printStackTrace(); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
59 |
throw new RuntimeException(failed); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
60 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
61 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
62 |
|
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
63 |
private static Thread testThread(int index) { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
64 |
return new Thread(new ThreadGroup("TG " + index), () -> { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
65 |
SunToolkit.createNewAppContext(); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
66 |
while (!isComplete()) { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
67 |
final Frame frame = new Frame(); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
68 |
frame.setSize(300, 300); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
69 |
frame.add(new Button("Button")); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
70 |
frame.setLocationRelativeTo(null); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
71 |
frame.setVisible(true); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
72 |
try { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
73 |
Thread.sleep(index); // increase probability of the failure |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
74 |
} catch (InterruptedException ignored) { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
75 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
76 |
frame.dispose(); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
77 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
78 |
}); |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
79 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
80 |
|
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
81 |
private static boolean isComplete() { |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
82 |
return endtime - System.nanoTime() < 0 || failed != null; |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
83 |
} |
50de7d1f6b64
8211435: Exception in thread "AWT-EventQueue-1" java.lang.IllegalArgumentException: null source
serb
parents:
diff
changeset
|
84 |
} |