--- a/jdk/src/windows/classes/sun/awt/windows/ThemeReader.java Thu May 08 19:18:36 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/ThemeReader.java Mon Jul 14 18:16:16 2014 +0400
@@ -60,18 +60,12 @@
new ReentrantReadWriteLock();
private static final Lock readLock = readWriteLock.readLock();
private static final Lock writeLock = readWriteLock.writeLock();
+ private static volatile boolean valid = false;
static void flush() {
- writeLock.lock();
- try {
- // Close old themes.
- for (Long value : widgetToTheme.values()) {
- closeTheme(value.longValue());
- }
- widgetToTheme.clear();
- } finally {
- writeLock.unlock();
- }
+ // Could be called on Toolkit thread, so do not try to aquire locks
+ // to avoid deadlock with theme initialization
+ valid = false;
}
public static native boolean isThemed();
@@ -98,6 +92,24 @@
// returns theme value
// this method should be invoked with readLock locked
private static Long getTheme(String widget) {
+ if (!valid) {
+ readLock.unlock();
+ writeLock.lock();
+ try {
+ if (!valid) {
+ // Close old themes.
+ for (Long value : widgetToTheme.values()) {
+ closeTheme(value);
+ }
+ widgetToTheme.clear();
+ valid = true;
+ }
+ } finally {
+ readLock.lock();
+ writeLock.unlock();
+ }
+ }
+
// mostly copied from the javadoc for ReentrantReadWriteLock
Long theme = widgetToTheme.get(widget);
if (theme == null) {
--- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java Thu May 08 19:18:36 2014 +0400
+++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java Mon Jul 14 18:16:16 2014 +0400
@@ -931,7 +931,16 @@
* Windows doesn't always send WM_SETTINGCHANGE when it should.
*/
private void windowsSettingChange() {
- EventQueue.invokeLater(this::updateProperties);
+ if (AppContext.getAppContext() == null) {
+ // We cannot post the update to any EventQueue. Listeners will
+ // be called on EDTs by DesktopPropertyChangeSupport
+ updateProperties();
+ } else {
+ // Cannot update on Toolkit thread.
+ // DesktopPropertyChangeSupport will call listeners on Toolkit
+ // thread if it has AppContext (standalone mode)
+ EventQueue.invokeLater(this::updateProperties);
+ }
}
private synchronized void updateProperties() {