jeudi 11 juin 2015

Hi I am working on a small project which is going to use reflection

I am having one problem with .invoke part. can you guys tell me what am I doing wrong...

private static void execute_Actions(Class<?> currentClass, Node node ) throws Exception {
        Object obj = currentClass.newInstance();
        Method method[] = obj.getClass().getDeclaredMethods();
        String action = ((Element)node).getAttribute("Action");
        if(action != null){
        for(int i = 0;i < method.length;i++){
            if(method[i].getName().equals(action)){
                System.out.println(method[i].getName());
                method[i].invoke(obj, node);
                    }
                }
            }
        }

Here nothing is happening. loop runs.. I can see in console the method name.. but it is not getting triggered...





Aucun commentaire:

Enregistrer un commentaire