Mercurial > hg > shenandoah-preopenjdk-archive > openjdk8 > jdk
changeset 9828:bd5f7651116e jdk8u11-b11
8042590: Running form URL throws NPE
Reviewed-by: anthony, serb
author | pchelko |
---|---|
date | Mon, 19 May 2014 14:10:44 +0400 |
parents | 8c58eec5ebdc |
children | f7321fdc37a8 cbdfb9fdf1b3 |
files | src/windows/classes/sun/awt/windows/ThemeReader.java src/windows/classes/sun/awt/windows/WToolkit.java src/windows/classes/sun/awt/windows/WWindowPeer.java |
diffstat | 3 files changed, 33 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/windows/classes/sun/awt/windows/ThemeReader.java Wed May 28 02:42:35 2014 -0700 +++ b/src/windows/classes/sun/awt/windows/ThemeReader.java Mon May 19 14:10:44 2014 +0400 @@ -56,18 +56,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 native static boolean isThemed(); @@ -94,6 +88,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/src/windows/classes/sun/awt/windows/WToolkit.java Wed May 28 02:42:35 2014 -0700 +++ b/src/windows/classes/sun/awt/windows/WToolkit.java Mon May 19 14:10:44 2014 +0400 @@ -867,7 +867,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() {
--- a/src/windows/classes/sun/awt/windows/WWindowPeer.java Wed May 28 02:42:35 2014 -0700 +++ b/src/windows/classes/sun/awt/windows/WWindowPeer.java Mon May 19 14:10:44 2014 +0400 @@ -436,6 +436,7 @@ @SuppressWarnings("unchecked") public static long[] getActiveWindowHandles() { AppContext appContext = AppContext.getAppContext(); + if (appContext == null) return null; synchronized (appContext) { List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY); if (l == null) {