Index: src/gate/Gate.java =================================================================== --- src/gate/Gate.java (revision 7462) +++ src/gate/Gate.java (working copy) @@ -104,8 +104,7 @@ lastSym = 0; // create class loader and creole register if they're null - if(classLoader == null) - classLoader = new GateClassLoader(Gate.class.getClassLoader()); + getClassLoader(); if(creoleRegister == null) creoleRegister = new CreoleRegisterImpl(); if(knownPlugins == null) knownPlugins = new ArrayList(); @@ -768,12 +767,30 @@ private static URL urlBase = null; /** Class loader used e.g. for loading CREOLE modules, of compiling - * JAPE rule RHSs. - */ - private static GateClassLoader classLoader = null; + * JAPE rule RHSs. + */ + private static GateClassLoader[] classLoader = new GateClassLoader[]{ null }; + + /** Get the GATE class loader. */ + public static GateClassLoader getClassLoader() + { + synchronized (classLoader) + { + if (classLoader[0] == null) + { + classLoader[0] = new GateClassLoader(Gate.class.getClassLoader()); + } + return classLoader[0]; + } + } - /** Get the GATE class loader. */ - public static GateClassLoader getClassLoader() { return classLoader; } + public static void resetClassLoader() + { + synchronized (classLoader) + { + classLoader[0] = null; + } + } /** The CREOLE register. */ private static CreoleRegister creoleRegister = null; Index: src/gate/util/Javac.java =================================================================== --- src/gate/util/Javac.java (revision 7462) +++ src/gate/util/Javac.java (working copy) @@ -48,7 +48,7 @@ * otherwise. */ private static void setCompilerTypeFromUserConfig() throws GateException { - if(classLoader == null) classLoader = Gate.getClassLoader(); + GateClassLoader classLoader = Gate.getClassLoader(); // see if the user has expressed a preference String compilerType = Gate.getUserConfig().getString(COMPILER_TYPE_KEY); // if not, use the default @@ -133,11 +133,6 @@ private static Javac compiler = null; /** - * The GATE class loader. - */ - private static GateClassLoader classLoader = null; - - /** * The default compiler to use. */ public static final String DEFAULT_COMPILER = "gate.util.compilers.Eclipse"; Index: src/gate/util/compilers/Eclipse.java =================================================================== --- src/gate/util/compilers/Eclipse.java (revision 7462) +++ src/gate/util/compilers/Eclipse.java (working copy) @@ -63,7 +63,7 @@ * raised. */ public void compile(final Map sources) throws GateException { - if(classLoader == null) classLoader = Gate.getClassLoader(); + final GateClassLoader classLoader = Gate.getClassLoader(); // store any problems that occur douring compilation final Map problems = new HashMap(); @@ -365,5 +365,4 @@ } } - private static GateClassLoader classLoader; } Index: src/gate/util/compilers/Sun.java =================================================================== --- src/gate/util/compilers/Sun.java (revision 7462) +++ src/gate/util/compilers/Sun.java (working copy) @@ -40,7 +40,6 @@ * raised. */ public void compile(Map sources)throws GateException{ - if(classLoader == null) classLoader = Gate.getClassLoader(); File workDir; File srcDir; File classesDir; @@ -217,6 +216,7 @@ "." + classesDirectory.getName(); } + GateClassLoader cl = Gate.getClassLoader(); for(int i = 0; i < files.length; i++){ if(files[i].isDirectory()) loadAllClasses(files[i], packageName); else{ @@ -226,11 +226,10 @@ filename.substring(0, filename.length() - 6); //load the class from the file byte[] bytes = Files.getByteArray(files[i]); - classLoader.defineGateClass(className, bytes, 0, bytes.length); + cl.defineGateClass(className, bytes, 0, bytes.length); } } } } - protected static GateClassLoader classLoader; }