I try access info(String var) method in a final class that has a non visible contstructor Class(String var0, Logger var1, LoggerContext var2)
try {
Constructor<? extends Logger> var0 = logger.getClass().getDeclaredConstructor(String.class, Logger.class, LoggerContext.class);
var0.setAccessible(true);
logger.getClass().getDeclaredMethod("info", String.class).invoke(var0.newInstance(), new String(message));
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e) {
e.printStackTrace();
}
and this is the error
java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
Aucun commentaire:
Enregistrer un commentaire