--- a/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java Fri Dec 08 09:37:28 2017 -0500
+++ b/src/java.desktop/windows/classes/sun/awt/windows/ThemeReader.java Sun Dec 10 15:29:26 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -61,6 +61,7 @@
private static final Lock readLock = readWriteLock.readLock();
private static final Lock writeLock = readWriteLock.writeLock();
private static volatile boolean valid = false;
+ private static volatile boolean isThemed;
static volatile boolean xpStyleEnabled;
@@ -70,7 +71,17 @@
valid = false;
}
- public static native boolean isThemed();
+ private static native boolean initThemes();
+
+ public static boolean isThemed() {
+ writeLock.lock();
+ try {
+ isThemed = initThemes();
+ return isThemed;
+ } finally {
+ writeLock.unlock();
+ }
+ }
public static boolean isXPStyleEnabled() {
return xpStyleEnabled;
@@ -98,6 +109,9 @@
// returns theme value
// this method should be invoked with readLock locked
private static Long getTheme(String widget) {
+ if (!isThemed) {
+ throw new IllegalStateException("Themes are not loaded");
+ }
if (!valid) {
readLock.unlock();
writeLock.lock();
--- a/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp Fri Dec 08 09:37:28 2017 -0500
+++ b/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp Sun Dec 10 15:29:26 2017 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -232,7 +232,7 @@
return FALSE;
}
-JNIEXPORT jboolean JNICALL Java_sun_awt_windows_ThemeReader_isThemed
+JNIEXPORT jboolean JNICALL Java_sun_awt_windows_ThemeReader_initThemes
(JNIEnv *env, jclass klass) {
static BOOL TryLoadingThemeLib = FALSE;
static BOOL Themed = FALSE;