diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 21187717..3bacd09c 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -7,6 +7,7 @@ import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -48,7 +49,7 @@ public final class JavaPluginLoader implements PluginLoader { final Server server; private final Pattern[] fileFilters = new Pattern[] { Pattern.compile("\\.jar$"), }; private final Map<String, Class<?>> classes = new HashMap<String, Class<?>>(); - private final Map<String, PluginClassLoader> loaders = new LinkedHashMap<String, PluginClassLoader>(); + private final Map<String, PluginClassLoader> loaders = Collections.synchronizedMap(new LinkedHashMap<String, PluginClassLoader>()); /** * This class was not meant to be constructed explicitly @@ -114,9 +115,6 @@ public final class JavaPluginLoader implements PluginLoader { } for (final String pluginName : description.getDepend()) { - if (loaders == null) { - throw new UnknownDependencyException(pluginName); - } PluginClassLoader current = loaders.get(pluginName); if (current == null) { @@ -186,14 +184,14 @@ public final class JavaPluginLoader implements PluginLoader { if (cachedClass != null) { return cachedClass; } else { - for (String current : loaders.keySet()) { - PluginClassLoader loader = loaders.get(current); - - try { - cachedClass = loader.findClass(name, false); - } catch (ClassNotFoundException cnfe) {} - if (cachedClass != null) { - return cachedClass; + synchronized (loaders) { + for (PluginClassLoader loader : loaders.values()) { + try { + cachedClass = loader.findClass(name, false); + } catch (ClassNotFoundException cnfe) {} + if (cachedClass != null) { + return cachedClass; + } } } } |