Reverted commits that broke plugin class loading, pending investigation.

This commit is contained in:
EvilSeph 2011-05-15 19:20:30 -04:00
parent 992f1f2bf3
commit 6590ff82f4

View File

@ -25,31 +25,23 @@ public class PluginClassLoader extends URLClassLoader {
} }
protected Class<?> findClass(String name, boolean checkGlobal) throws ClassNotFoundException { 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); Class<?> result = classes.get(name);
if (null == result) { if (result == null) {
try {
result = super.findClass(name);
classes.put(name, result);
loader.setClass(name, result);
} catch (ClassNotFoundException e) {
if (checkGlobal) { if (checkGlobal) {
result = loader.getClassByName(name); 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) {
result = super.findClass(name);
if (result != null) {
loader.setClass(name, result);
} }
} }
// NOTE: setClass already does a not exists check classes.put(name, result);
loader.setClass(name, result); }
return result; return result;
} }