I've tested on three windows machines, and two linux VPSes, on different versions of Java, both on the OpenJDK & Oracle JDK. It functioned perfectly, and then all of a sudden, it only works in my IDE, though I haven't changed any relevant code, and I can't imagine what can cause this.
Prevalent code in system:
Class<?> cls = (session == null ? secjlcl : session.getJLCL()).loadClass(name);
Logger.log(JavaLoader.class.isAssignableFrom(cls) + " - " + cls + " - " + cls.getSuperclass().getName());
if (JavaLoader.class.isAssignableFrom(cls)) {
And my ClassLoader:
public class JavaLoaderClassLoader extends URLClassLoader {
public JavaLoaderClassLoader(URL[] url, ClassLoader parent) {
super(url);
}
private HashMap<String, Class<?>> javaLoaders = new HashMap<String, Class<?>>();
public String addClass(byte[] data) throws LinkageError {
Class<?> cls = defineClass(null, data, 0, data.length);
javaLoaders.put(cls.getName(), cls);
return cls.getName();
}
public Class<?> loadClass(String name, boolean resolve) {
if (javaLoaders.containsKey(name)) return javaLoaders.get(name);
try {
Class<?> see = super.loadClass(name, resolve);
if (see != null) return see;
}catch (ClassNotFoundException e) {
Logger.logError(e);
}
return null;
}
public void finalize() throws Throwable {
super.finalize();
javaLoaders = null;
}
}
One note, I expect many classloaders to load a different file in the same name/package, so I use separate classloaders to keep them separate, however in testing, that was NOT tested.
Now, this had worked flawlessly in the past, and I have zero clue why it stopped. I would assume I broke something, but the code still works in my IDE?
System.out.println(cls.getClassLoader()+" "+JavaLoader.class.getClassLoader());
print - two different things, or the same things twice?