I have 2 ClassLoaders, one which I don't have access to source code and second which I'm loading classes now. ( I'm using java agents to inject code. )
My problem is when I try to load class which has been loaded by the different ClassLoader, it's not working.
// some different class loader
// also this is the ClassLoader which loaded GL11
ClassLoader cl = getDifferentClassLoader();
this.getClass().getClassLoader() == cl // false
GL11.glPushMatrix(); // NoClassDefFoundError
But when I call it using reflection, it works
Class<?> clazz = cl.loadClass("org.lwjgl.opengl.GL11");
clazz.getDeclaredMethod("glPushMatrix").invoke(null); // this works
I tried something like this but it's not working :(
Thread.currentThread().setContextClassLoader(cl);
GL11.glPushMatrix();
Is something like this possible?
Aucun commentaire:
Enregistrer un commentaire