mardi 31 janvier 2017

newInstance() cannot find constructor that exist

I think that I am missing something. I am trying to do next thing:

Class.forName(className).getConstructor(getParameterTypes(parameters)).newInstance(parameters);

I am getting error

java.lang.NoSuchMethodException: MyClass.<init>(java.lang.Class)

My class name is full class name(with packages). Method getParameterTypes is returning class java.lang.Class. parameters variable is type of Class and in MyClass I have constructor that is accepting Class. Do someone know what is the problem?





Aucun commentaire:

Enregistrer un commentaire