public Object invoke()

in core/src/main/java/org/apache/commons/proxy2/invoker/DuckTypingInvoker.java [88:107]


    public Object invoke(final Object proxy, final Method method, final Object[] arguments) throws Throwable
    {
        final Object target = targetProvider.getObject();
        final Class<?> targetClass = target.getClass();
        try
        {
            final Method targetMethod = targetClass.getMethod(method.getName(), method.getParameterTypes());
            if (method.getReturnType().isAssignableFrom(targetMethod.getReturnType()))
            {
                return targetMethod.invoke(target, arguments);
            }
            throw new UnsupportedOperationException("Target type " + targetClass.getName()
                    + " method has incompatible return type.");
        }
        catch (NoSuchMethodException e)
        {
            throw new UnsupportedOperationException("Target type " + targetClass.getName()
                    + " does not have a method matching " + method + ".", e);
        }
    }