@Override public Object invoke( Object object, Method method, Object[] args ) throws Throwable { if( delegate instanceof InvocationHandler ) { InvocationHandler handler = (InvocationHandler) delegate; return handler.invoke( object, method, args ); } else { try { return method.invoke( delegate, args ); } catch( InvocationTargetException e ) { throw e.getCause(); } catch( IllegalArgumentException e ) { String message = constructMessage( method, args ); throw new IllegalArgumentException( message, e ); } } }
@Override public Object invoke( Object object, Method method, Object[] args ) throws Throwable { if( delegate instanceof InvocationHandler ) { InvocationHandler handler = (InvocationHandler) delegate; return handler.invoke( object, method, args ); } else { try { return method.invoke( delegate, args ); } catch( InvocationTargetException e ) { throw e.getCause(); } catch( IllegalArgumentException e ) { String message = constructMessage( method, args ); throw new IllegalArgumentException( message, e ); } } }