private static Object invokeOrDie ( final Method method , final Object object , final Object ... params ) { try { return method . invoke ( object , params ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( "Couldn't use Java reflection to implement protocol message " + "reflection." , e ) ; } catch ( InvocationTargetException e ) { final Throwable cause = e . getCause ( ) ; if ( cause instanceof RuntimeException ) { throw ( RuntimeException ) cause ; } else if ( cause instanceof Error ) { throw ( Error ) cause ; } else { throw new RuntimeException ( "Unexpected exception thrown by generated accessor method." , cause ) ; } } }
Calls invoke and throws a RuntimeException if it fails .