samedi 27 février 2016

How to get class from field?

I am trying to receive class field value via reflection. But when I call my code I receive exception: IllegalArgumentException: Can not set class field field to java.lang.Class.

My code:

Field f = clz.getDeclaredField("classLoader");
f.setAccessible(true);
Class cls = f.get(clz).getClass();

Code from class with field:

public class SomeClass{
    public RelaunchClassLoader classLoader;

    //Other code

}

RelaunchClassLoader extends URLClassLoader

What's wrong?





Aucun commentaire:

Enregistrer un commentaire