core/src/main/java/org/springframework/security/util/MethodInvocationUtils.java
public static MethodInvocation create(Object object, String methodName,
			Object... args) {
		Assert.notNull(object, "Object required");

		Class<?>[] classArgs = null;

		if (args != null) {
			classArgs = new Class<?>[args.length];

			for (int i = 0; i < args.length; i++) {
				classArgs[i] = args[i].getClass();
			}
		}

		// Determine the type that declares the requested method, taking into account
		// proxies
		Class<?> target = AopUtils.getTargetClass(object);
		if (object instanceof Advised) {
			Advised a = (Advised) object;
			if (!a.isProxyTargetClass()) {
				Class<?>[] possibleInterfaces = a.getProxiedInterfaces();
				for (Class<?> possibleInterface : possibleInterfaces) {
					try {
						possibleInterface.getMethod(methodName, classArgs);
						// to get here means no exception happened
						target = possibleInterface;
						break;
					}
					catch (Exception ignored) {
						// try the next one
					}
				}
			}
		}

		return createFromClass(object, target, methodName, classArgs, args);
	}
public static MethodInvocation create(Object object, String methodName,
			Object... args) {
		Assert.notNull(object, "Object required");

		Class<?>[] classArgs = null;

		if (args != null) {
			classArgs = new Class<?>[args.length];

			for (int i = 0; i < args.length; i++) {
				classArgs[i] = args[i].getClass();
			}
		}

		// Determine the type that declares the requested method, taking into account
		// proxies
		Class<?> target = AopUtils.getTargetClass(object);
		if (object instanceof Advised) {
			Advised a = (Advised) object;
			if (!a.isProxyTargetClass()) {
				Class<?>[] possibleInterfaces = a.getProxiedInterfaces();
				for (Class<?> possibleInterface : possibleInterfaces) {
					try {
						possibleInterface.getMethod(methodName, classArgs);
						// to get here means no exception happened
						target = possibleInterface;
						break;
					}
					catch (Exception ignored) {
						// try the next one
					}
				}
			}
		}

		return createFromClass(object, target, methodName, classArgs, args);
	}
public static MethodInvocation create ( Object object , String methodName , Object ... args ) { Assert . notNull ( object , "Object required" ) ; Class < ? > [ ] classArgs = null ; if ( args != null ) { classArgs = new Class < ? > [ args . length ] ; for ( int i = 0 ; i < args . length ; i ++ ) { classArgs [ i ] = args [ i ] . getClass ( ) ; } } // Determine the type that declares the requested method, taking into account // proxies Class < ? > target = AopUtils . getTargetClass ( object ) ; if ( object instanceof Advised ) { Advised a = ( Advised ) object ; if ( ! a . isProxyTargetClass ( ) ) { Class < ? > [ ] possibleInterfaces = a . getProxiedInterfaces ( ) ; for ( Class < ? > possibleInterface : possibleInterfaces ) { try { possibleInterface . getMethod ( methodName , classArgs ) ; // to get here means no exception happened target = possibleInterface ; break ; } catch ( Exception ignored ) { // try the next one } } } } return createFromClass ( object , target , methodName , classArgs , args ) ; }
Generates a <code>MethodInvocation</code> for specified <code>methodName</code> on
the passed object, using the <code>args</code> to locate the method.

@param object the object that will be used to find the relevant <code>Method</code>
@param methodName the name of the method to find
@param args arguments that are required as part of the method signature (can be
empty)

@return a <code>MethodInvocation</code>, or <code>null</code> if there was a
problem
Generates a <code > MethodInvocation< / code > for specified <code > methodName< / code > on the passed object using the <code > args< / code > to locate the method .