From be3c68fada7cf9503f3d501d29283628e0056bcb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 7 Mar 2012 03:27:11 +0100 Subject: TempJarCache: Check for NULL jarURL and reuse contains queries --- .../com/jogamp/common/util/cache/TempJarCache.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/java/com/jogamp') diff --git a/src/java/com/jogamp/common/util/cache/TempJarCache.java b/src/java/com/jogamp/common/util/cache/TempJarCache.java index dd3e306..162b151 100644 --- a/src/java/com/jogamp/common/util/cache/TempJarCache.java +++ b/src/java/com/jogamp/common/util/cache/TempJarCache.java @@ -152,16 +152,25 @@ public class TempJarCache { public static boolean containsNativeLibs(URL jarURL) throws IOException { checkInitialized(); + if(null == jarURL) { + throw new IllegalArgumentException("jarURL is null"); + } return nativeLibJars.contains(jarURL); } public static boolean containsClasses(URL jarURL) throws IOException { checkInitialized(); + if(null == jarURL) { + throw new IllegalArgumentException("jarURL is null"); + } return classFileJars.contains(jarURL); } public static boolean containsResources(URL jarURL) throws IOException { checkInitialized(); + if(null == jarURL) { + throw new IllegalArgumentException("jarURL is null"); + } return resourceFileJars.contains(jarURL); } @@ -175,8 +184,7 @@ public class TempJarCache { * @throws SecurityException */ public static final void addNativeLibs(Class certClass, URL jarURL, ClassLoader cl) throws IOException, SecurityException { - checkInitialized(); - if(!nativeLibJars.contains(jarURL)) { + if(!containsNativeLibs(jarURL)) { final JarFile jarFile = JarUtil.getJarFile(jarURL, cl); if(DEBUG) { System.err.println("TempJarCache: addNativeLibs: "+jarURL+": nativeJar "+jarFile.getName()); @@ -201,8 +209,7 @@ public class TempJarCache { * @throws SecurityException */ public static final void addClasses(Class certClass, URL jarURL, ClassLoader cl) throws IOException, SecurityException { - checkInitialized(); - if(!classFileJars.contains(jarURL)) { + if(!containsClasses(jarURL)) { final JarFile jarFile = JarUtil.getJarFile(jarURL, cl); if(DEBUG) { System.err.println("TempJarCache: addClasses: "+jarURL+": nativeJar "+jarFile.getName()); @@ -225,8 +232,7 @@ public class TempJarCache { * @throws SecurityException */ public static final void addResources(Class certClass, URL jarURL, ClassLoader cl) throws IOException, SecurityException { - checkInitialized(); - if(!resourceFileJars.contains(jarURL)) { + if(!containsResources(jarURL)) { final JarFile jarFile = JarUtil.getJarFile(jarURL, cl); if(DEBUG) { System.err.println("TempJarCache: addResources: "+jarURL+": nativeJar "+jarFile.getName()); @@ -253,6 +259,9 @@ public class TempJarCache { */ public static final void addAll(Class certClass, URL jarURL, ClassLoader cl) throws IOException, SecurityException { checkInitialized(); + if(null == jarURL) { + throw new IllegalArgumentException("jarURL is null"); + } if(!nativeLibJars.contains(jarURL) || !classFileJars.contains(jarURL) || !resourceFileJars.contains(jarURL)) { -- cgit v1.2.3