@ SuppressWarnings ( "unchecked" ) public static synchronized < T > T invokeMethod ( Object object , Class < ? > declaringClass , String methodToExecute , Class < ? > [ ] parameterTypes , Object ... arguments ) throws Exception { if ( object == null ) { throw new IllegalArgumentException ( "object cannot be null" ) ; } final Method methodToInvoke = getMethod ( declaringClass , methodToExecute , parameterTypes ) ; // Invoke method return ( T ) performMethodInvocation ( object , methodToInvoke , arguments ) ; }
Invoke a private method in that is located in a subclass of an instance . This might be useful to test overloaded private methods .