public static Object callMethod(Object obj, String name, Object ...args) {
        Class<?>[] argsC = new Class[args.length];
        for (int i =0; i < args.length; i++) {
            if (args[i] == null) {
                argsC[i] = null;
                continue;
            }
            argsC[i] = args.getClass(); 
        }
        
        try {
            Method m = obj.getClass().getDeclaredMethod(name, argsC);
            boolean b = m.isAccessible();
            m.setAccessible(true);
            Object ret = m.invoke(obj, args);
            m.setAccessible(b);
            return ret;
        } catch (SecurityException e) {
            throw new RuntimeException(e);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
public static Object callMethod ( Object obj , String name , Object ... args ) { Class < ? > [ ] argsC = new Class [ args . length ] ; for ( int i = 0 ; i < args . length ; i ++ ) { if ( args [ i ] == null ) { argsC [ i ] = null ; continue ; } argsC [ i ] = args . getClass ( ) ; } try { Method m = obj . getClass ( ) . getDeclaredMethod ( name , argsC ) ; boolean b = m . isAccessible ( ) ; m . setAccessible ( true ) ; Object ret = m . invoke ( obj , args ) ; m . setAccessible ( b ) ; return ret ; } catch ( SecurityException e ) { throw new RuntimeException ( e ) ; } catch ( NoSuchMethodException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( InvocationTargetException e ) { throw new RuntimeException ( e ) ; } }
@param obj The object
@param name The method name
@param args The method args
@return Result.