core/src/main/java/org/sakaiproject/nakamura/api/lite/StorageClientUtils.java
private static Object safeMethod(Object target, String methodName, Object[] args,
            @SuppressWarnings("rawtypes") Class[] argsTypes) {
        if (target != null) {
            try {
                Method m = target.getClass().getMethod(methodName, argsTypes);
                if (!m.isAccessible()) {
                    m.setAccessible(true);
                }
                return m.invoke(target, args);
            } catch (Throwable e) {
                LOGGER.info("Failed to invoke method " + methodName + " " + target, e);
            }
        }
        return null;
    }
private static Object safeMethod(Object target, String methodName, Object[] args,
            @SuppressWarnings("rawtypes") Class[] argsTypes) {
        if (target != null) {
            try {
                Method m = target.getClass().getMethod(methodName, argsTypes);
                if (!m.isAccessible()) {
                    m.setAccessible(true);
                }
                return m.invoke(target, args);
            } catch (Throwable e) {
                LOGGER.info("Failed to invoke method " + methodName + " " + target, e);
            }
        }
        return null;
    }
private static Object safeMethod ( Object target , String methodName , Object [ ] args , @ SuppressWarnings ( "rawtypes" ) Class [ ] argsTypes ) { if ( target != null ) { try { Method m = target . getClass ( ) . getMethod ( methodName , argsTypes ) ; if ( ! m . isAccessible ( ) ) { m . setAccessible ( true ) ; } return m . invoke ( target , args ) ; } catch ( Throwable e ) { LOGGER . info ( "Failed to invoke method " + methodName + " " + target , e ) ; } } return null ; }
Make the method on the target object accessible and then invoke it.
@param target the object with the method to invoke
@param methodName the name of the method to invoke
@param args the arguments to pass to the invoked method
@param argsTypes the types of the arguments being passed to the method
@return
Make the method on the target object accessible and then invoke it .