samedi 15 décembre 2018

Load a class which implement another one - Java

I'm trying to load some classes dynamically bvy getting their bytes and using reflection to use the defineClass method. Here is my code

Method m = java.lang.ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
            m.setAccessible(true);
            m.invoke(Main.class.getClassLoader(), k, v, 0, v.length);





Aucun commentaire:

Enregistrer un commentaire