dimanche 28 octobre 2018

Java reflection - Call protected class with public constructor that accepts Interface as argument

I would like to call a protected class that consists of a public constructor via reflection. Following is my code

final Class clazz = Whitebox.getInnerClassType(parentClass.getClass(), 
"InnerClassName");
final Constructor constructor = Whitebox.getConstructor(clazz,AnInterface.class);
statusPage = constructor.newInstance(iInvokeContext);

Im getting the below exception:

org.powermock.reflect.exceptions.ConstructorNotFoundException: Failed to lookup constructor with parameter types      

I think is the problem might be since the constuctor argument is an interface.





Aucun commentaire:

Enregistrer un commentaire