Skip to content

Commit 82491fd

Browse files
committed
7105119: [TEST_BUG] [macosx] In test UIDefaults.toString() must be called with the invokeLater()
Backport-of: 84fc485
1 parent d66464e commit 82491fd

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,6 @@ javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all
755755
javax/swing/JPopupMenu/4966112/bug4966112.java 8064915 macosx-all
756756
javax/swing/JSpinner/8223788/JSpinnerButtonFocusTest.java 8238085 macosx-all
757757
javax/swing/MultiUIDefaults/Test6860438.java 8198391 generic-all
758-
javax/swing/MultiUIDefaults/4300666/bug4300666.java 7105119 macosx-all
759758
javax/swing/UITest/UITest.java 8198392 generic-all
760759
javax/swing/plaf/basic/BasicComboBoxEditor/Test8015336.java 8198394 generic-all
761760
javax/swing/plaf/metal/MetalLookAndFeel/Test8039750.java 8198395 generic-all

test/jdk/javax/swing/MultiUIDefaults/4300666/bug4300666.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,34 @@
2727
* @summary Printing UIDefaults throws NoSuchElementExcept
2828
*/
2929

30-
import javax.swing.*;
30+
import java.awt.EventQueue;
3131

32-
public class bug4300666 {
32+
import javax.swing.UIDefaults;
33+
import javax.swing.UIManager;
34+
import javax.swing.UnsupportedLookAndFeelException;
3335

34-
public static void main(final String[] args) {
35-
UIDefaults d = UIManager.getDefaults();
36-
d.toString();
36+
import static javax.swing.UIManager.getInstalledLookAndFeels;
37+
38+
public final class bug4300666 {
39+
40+
public static void main(final String[] args) throws Exception {
41+
for (UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
42+
EventQueue.invokeAndWait(() -> setLookAndFeel(laf));
43+
EventQueue.invokeAndWait(() -> {
44+
UIDefaults d = UIManager.getDefaults();
45+
d.toString();
46+
});
47+
}
48+
}
49+
50+
private static void setLookAndFeel(UIManager.LookAndFeelInfo laf) {
51+
try {
52+
UIManager.setLookAndFeel(laf.getClassName());
53+
} catch (UnsupportedLookAndFeelException ignored) {
54+
System.out.println("Unsupported L&F: " + laf.getClassName());
55+
} catch (ClassNotFoundException | InstantiationException
56+
| IllegalAccessException e) {
57+
throw new RuntimeException(e);
58+
}
3759
}
3860
}

0 commit comments

Comments
 (0)