public static void addToStart ( MethodGen mg , InstructionList newList ) { // Add the code before the first instruction InstructionList il = mg . getInstructionList ( ) ; InstructionHandle oldStart = il . getStart ( ) ; InstructionHandle newStart = il . insert ( newList ) ; // Move any LineNumbers and local variables that currently point to // the first instruction to include the new instructions. Other // targeters (branches, exceptions) should not include the new code. if ( oldStart . hasTargeters ( ) ) { // getTargeters() returns non-null because hasTargeters => true for ( InstructionTargeter it : oldStart . getTargeters ( ) ) { if ( ( it instanceof LineNumberGen ) || ( it instanceof LocalVariableGen ) ) { it . updateTarget ( oldStart , newStart ) ; } } } mg . setMaxStack ( ) ; mg . setMaxLocals ( ) ; }
Adds instructions to the start of a method .