diff options
-rwxr-xr-x | make/scripts/runtest.sh | 6 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/cache/TempJarCache.java | 25 |
2 files changed, 24 insertions, 7 deletions
diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh index 028eae2..61257d1 100755 --- a/make/scripts/runtest.sh +++ b/make/scripts/runtest.sh @@ -52,7 +52,7 @@ rm -f $LOG #D_ARGS="-Djogamp.debug.Lock" #D_ARGS="-Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogamp.debug.Lock.TraceLock" -D_ARGS="-Djogamp.debug.IOUtil" +#D_ARGS="-Djogamp.debug.IOUtil" #D_ARGS="-Djogamp.debug=all" function onetest() { @@ -95,8 +95,8 @@ function onetest() { #onetest com.jogamp.common.util.TestRunnableTask01 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestIOUtil01 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestIOUtilURICompose 2>&1 | tee -a $LOG -onetest com.jogamp.common.util.TestIOUtilURIHandling 2>&1 | tee -a $LOG -#onetest com.jogamp.common.util.TestTempJarCache 2>&1 | tee -a $LOG +#onetest com.jogamp.common.util.TestIOUtilURIHandling 2>&1 | tee -a $LOG +onetest com.jogamp.common.util.TestTempJarCache 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestJarUtil 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestValueConversion 2>&1 | tee -a $LOG #onetest com.jogamp.common.util.TestSyncRingBuffer01 $* diff --git a/src/java/com/jogamp/common/util/cache/TempJarCache.java b/src/java/com/jogamp/common/util/cache/TempJarCache.java index 48d8081..c127314 100644 --- a/src/java/com/jogamp/common/util/cache/TempJarCache.java +++ b/src/java/com/jogamp/common/util/cache/TempJarCache.java @@ -74,7 +74,7 @@ public class TempJarCache { private static TempFileCache tmpFileCache; - private static boolean staticInitError = false; + private static volatile boolean staticInitError = false; private static volatile boolean isInit = false; /** @@ -86,7 +86,6 @@ public class TempJarCache { if (!isInit) { // volatile: ok synchronized (TempJarCache.class) { if (!isInit) { - isInit = true; staticInitError = !TempFileCache.initSingleton(); if(!staticInitError) { @@ -104,6 +103,7 @@ public class TempJarCache { if(DEBUG) { System.err.println("TempJarCache.initSingleton(): ok "+(false==staticInitError)+", "+ tmpFileCache.getTempDir()); } + isInit = true; } } } @@ -150,17 +150,31 @@ public class TempJarCache { } } */ + private static boolean isInitializedImpl() { + if (!isInit) { // volatile: ok + synchronized (TempJarCache.class) { + if (!isInit) { + return false; + } + } + } + return true; + } + /** * @return true if this class has been properly initialized, ie. is in use, otherwise false. */ public static boolean isInitialized() { - return isInit && !staticInitError; + return isInitializedImpl() && !staticInitError; } /* package */ static void checkInitialized() { - if(!isInit) { + if(!isInitializedImpl()) { throw new RuntimeException("initSingleton() has to be called first."); } + if(staticInitError) { + throw new RuntimeException("initSingleton() failed."); + } } public static TempFileCache getTempFileCache() { @@ -205,6 +219,7 @@ public class TempJarCache { * @throws IllegalArgumentException */ public synchronized static final boolean addNativeLibs(Class<?> certClass, URI jarURI, String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { + checkInitialized(); final LoadState nativeLibJarsLS = nativeLibJars.get(jarURI); if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) ) { nativeLibJars.put(jarURI, LoadState.LOOKED_UP); @@ -239,6 +254,7 @@ public class TempJarCache { * @throws IllegalArgumentException */ public synchronized static final void addClasses(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { + checkInitialized(); final LoadState classFileJarsLS = classFileJars.get(jarURI); if( !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) ) { classFileJars.put(jarURI, LoadState.LOOKED_UP); @@ -267,6 +283,7 @@ public class TempJarCache { * @throws IllegalArgumentException */ public synchronized static final void addResources(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { + checkInitialized(); final LoadState resourceFileJarsLS = resourceFileJars.get(jarURI); if( !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP) ) { resourceFileJars.put(jarURI, LoadState.LOOKED_UP); |