@SuppressWarnings("unchecked") // Single-interface proxy creation guarded by parameter safety.
    public <T> T create(final Class<T> service) {
        Utils.validateServiceInterface(service);
        if (validateEagerly) {
            eagerlyValidateMethods(service);
        }
        return (T) Proxy.newProxyInstance(service.getClassLoader(), new Class<?>[]{service},
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object... args)
                            throws Throwable {
                        // If the method is a method from Object then defer to normal invocation.
                        if (method.getDeclaringClass() == Object.class) {
                            return method.invoke(this, args);
                        }
                        return loadMethodHandler(method).invoke(args);
                    }
                });
    }
@ SuppressWarnings ( "unchecked" ) public < T > T create ( final Class < T > service ) { Utils . validateServiceInterface ( service ) ; if ( validateEagerly ) { eagerlyValidateMethods ( service ) ; } return ( T ) Proxy . newProxyInstance ( service . getClassLoader ( ) , new Class < ? > [ ] { service } , new InvocationHandler ( ) { @ Override public Object invoke ( Object proxy , Method method , Object ... args ) throws Throwable { if ( method . getDeclaringClass ( ) == Object . class ) { return method . invoke ( this , args ) ; } return loadMethodHandler ( method ) . invoke ( args ) ; } } ) ; }
Create an implementation of the API defined by the {@code service} interface.