mercredi 15 avril 2015

NoSuchMethodException when using reflection to get defineClass from ClassLoader

I'm trying to use reflection to get the defineClass method from ClassLoader



ClassLoader cl = this.getClass().getClassLoader();
Method m = cl.getClass().getMethod("defineClass", new Class[] { String.class, Array.class, int.class, int.class });


but this fails with a NoSuchMethodException: sun.misc.Launcher$AppClassLoader.defineClass(java.lang.String, java.lang.reflect.Array, int, int)


It seems plausible that it doesn't like the Array.class, but if so, I have no idea what would be required there.






Aucun commentaire:

Enregistrer un commentaire