private void invokeReflection ( Method method , String signature ) { GeneratorAdapter mg = new GeneratorAdapter ( Opcodes . ACC_PUBLIC , method , signature , new Type [ 0 ] , classWriter ) ; /** * try { * // Call method * } catch (IllegalAccessException e) { * throw Throwables.propagate(e); * } */ Label beginTry = mg . newLabel ( ) ; Label endTry = mg . newLabel ( ) ; Label catchHandle = mg . newLabel ( ) ; mg . visitTryCatchBlock ( beginTry , endTry , catchHandle , Type . getInternalName ( IllegalAccessException . class ) ) ; mg . mark ( beginTry ) ; mg . loadThis ( ) ; mg . getField ( Type . getObjectType ( className ) , "field" , Type . getType ( Field . class ) ) ; mg . loadArgs ( ) ; mg . invokeVirtual ( Type . getType ( Field . class ) , method ) ; mg . mark ( endTry ) ; mg . returnValue ( ) ; mg . mark ( catchHandle ) ; int exception = mg . newLocal ( Type . getType ( IllegalAccessException . class ) ) ; mg . storeLocal ( exception ) ; mg . loadLocal ( exception ) ; mg . invokeStatic ( Type . getType ( Throwables . class ) , getMethod ( RuntimeException . class , "propagate" , Throwable . class ) ) ; mg . throwException ( ) ; mg . endMethod ( ) ; }
Generates the try - catch block that wrap around the given reflection method call .