private static MessageBuffer newInstance ( Constructor < ? > constructor , Object ... args ) { try { // We need to use reflection to create MessageBuffer instances in order to prevent TypeProfile generation for getInt method. TypeProfile will be // generated to resolve one of the method references when two or more classes overrides the method. return ( MessageBuffer ) constructor . newInstance ( args ) ; } catch ( InstantiationException e ) { // should never happen throw new IllegalStateException ( e ) ; } catch ( IllegalAccessException e ) { // should never happen unless security manager restricts this reflection throw new IllegalStateException ( e ) ; } catch ( InvocationTargetException e ) { if ( e . getCause ( ) instanceof RuntimeException ) { // underlying constructor may throw RuntimeException throw ( RuntimeException ) e . getCause ( ) ; } else if ( e . getCause ( ) instanceof Error ) { throw ( Error ) e . getCause ( ) ; } // should never happen throw new IllegalStateException ( e . getCause ( ) ) ; } }
Creates a new MessageBuffer instance