lundi 15 janvier 2018

java reflect method.invoke is not working

I'm trying to invoke a function using Method. The thing is the below code is not executing. I tried searching and it all ended the same. Can someone throw some light why it is not working? I had tried putting some log and it all reached until method.invoke function. There has been no exception thrown for the below code.

public String customSearchedParams() throws Exception
    {
            Class<?> dynamicObj = Class.forName(this.className);
            Constructor<?> constructor = dynamicObj.getConstructor(long.class, long.class, long.class, long.class);
            Object obj = constructor.newInstance(this.startTime, this.time, this.t1, this.t2);                
            Method method = dynamicObj.getMethod("getCustomSearch", new Class[]{long.class, long.class, long.class, long.class, long.class});
            this.data = (String) method.invoke(obj, new Object[]{this.startTime, this.time, this.t1, this.t2, this.paramIDs});
            return "SUCCESS";
    }





Aucun commentaire:

Enregistrer un commentaire