Reverted commits that broke plugin class loading, pending investigation.

By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
Bukkit/Spigot 2011-05-15 19:20:30 -04:00
parent 855f4133b6
commit 8afcd239d8

View file

@ -25,31 +25,23 @@ public class PluginClassLoader extends URLClassLoader {
}
protected Class<?> findClass(String name, boolean checkGlobal) throws ClassNotFoundException {
// We use the following load order:
// 1. Local first, this avoids IllegalAccessError exceptions for duplicate classes
// 2. Global cache second which prevents ClassCastException's apparently
Class<?> result = classes.get(name);
if (null == result) {
try {
if (result == null) {
if (checkGlobal) {
result = loader.getClassByName(name);
}
if (result == null) {
result = super.findClass(name);
classes.put(name, result);
loader.setClass(name, result);
} catch (ClassNotFoundException e) {
if (checkGlobal) {
result = loader.getClassByName(name);
if (null == result) {
// We really couldnt find it
throw new ClassNotFoundException(name);
}
} else {
throw e; // no more options just rethrow
if (result != null) {
loader.setClass(name, result);
}
}
}
// NOTE: setClass already does a not exists check
loader.setClass(name, result);
classes.put(name, result);
}
return result;
}