If I have this class that I cannot modify...
public abstract class AClass {
Object value;
public AClass(Object value) { this.value = value; }
}
Then how would I create an instance of it with reflection?
This...
Class<?> clazz = // some class
Constructor</*someClass*/> constructor = AClass.class.getConstructor(clazz);
Object key = clazz.getConstructor(Object.class).newInstance(/*something*/);
/*someClassResult */ result = constructor.newInstance(key);
throws an InstantiationException at the last line.
Aucun commentaire:
Enregistrer un commentaire