Siempre debes de utilizar la ruta completa a la clase.
Un ejemplo:
Código Javascript
:
Ver originalScanner scanner = new Scanner(System.in);
Class<?> clazz = Class.forName("mx.com.leviathan.data.filter.FilterExample");
if (clazz.isAnnotationPresent(Filter.class)) {
Object newInstance = clazz.newInstance();
Filter filter = clazz.getAnnotation(Filter.class);
System.out.printf("%s, %s %s\n", filter.author(), filter.name(), filter.version());
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.isAnnotationPresent(FilterFunction.class)) {
FilterFunction filterFunction = method.getAnnotation(FilterFunction.class);
if (filterFunction.params().length != filterFunction.paramTypes().length) {
System.err.println("El numero de argumentos es invalido!!");
return;
}
ArrayList<Object> params = new ArrayList<>();
for (int i = 0; i < filterFunction.params().length; i++) {
System.out.printf("Ingresa el parametro: %s >> ", filterFunction.params()[i]);
Object param = scanner.nextLine();
params.add(param);
}
Object result = method.invoke(newInstance, params.toArray());
System.out.printf("%s: %s\n", filterFunction.returnType(), result);
}
}
}