private void interceptInvokeVirtualMethodWithInvokeDynamic ( ListIterator < AbstractInsnNode > instructions , MethodInsnNode targetMethod ) { instructions . remove ( ) ; // remove the method invocation Type type = Type . getObjectType ( targetMethod . owner ) ; String description = targetMethod . desc ; String owner = type . getClassName ( ) ; if ( targetMethod . getOpcode ( ) != Opcodes . INVOKESTATIC ) { String thisType = type . getDescriptor ( ) ; description = "(" + thisType + description . substring ( 1 ) ; } instructions . add ( new InvokeDynamicInsnNode ( targetMethod . name , description , BOOTSTRAP_INTRINSIC , owner ) ) ; }
Intercepts the method using the invokedynamic bytecode instruction available in Java 7 + . Should be called through interceptInvokeVirtualMethod not directly .