question: protected void insertCode ( int offset , int count ) { if ( _jumps == null ) analyzeJumps ( ) ; if ( offset <= _offset ) { _offset += count ; } for ( int i = 0 ; i < _jumps . size ( ) ; i ++ ) { Jump jump = _jumps . get ( i ) ; jump . insert ( this , offset , count ) ; } ArrayList < CodeAttribute . ExceptionItem > exns = getExceptions ( ) ; for ( int i = 0 ; i < exns . size ( ) ; i ++ ) { CodeAttribute . ExceptionItem exn = exns . get ( i ) ; if ( offset <= exn . getStart ( ) ) exn . setStart ( exn . getStart ( ) + count ) ; if ( offset <= exn . getEnd ( ) ) exn . setEnd ( exn . getEnd ( ) + count ) ; if ( offset <= exn . getHandler ( ) ) exn . setHandler ( exn . getHandler ( ) + count ) ; } if ( _pendingTargets != null ) { for ( int i = _pendingTargets . size ( ) - 1 ; i >= 0 ; i -- ) { int target = _pendingTargets . get ( i ) ; if ( offset <= target ) _pendingTargets . set ( i , target + count ) ; } for ( int i = _completedTargets . size ( ) - 1 ; i >= 0 ; i -- ) { int target = _completedTargets . get ( i ) ; if ( offset <= target ) _completedTargets . set ( i , target + count ) ; } } for ( int i = 0 ; i < _switches . size ( ) ; i ++ ) { Branch branch = _switches . get ( i ) ; branch . insert ( this , offset , count ) ; } for ( int i = 0 ; i < count ; i ++ ) _code . add ( offset , 0 ) ; for ( int i = 0 ; i < _switches . size ( ) ; i ++ ) { Switch branch = _switches . get ( i ) ; branch . insertPad ( this , offset , count ) ; } }
target:  Updates indices when adding a chunk of code.  The operation at the given offset moves, e.g. adding 6 bytes to the beginning of the program moves the initial byte down by 6 and therefore needs to update the links as well. Therefore, enhancers which expand an opcode from 2 bytes to 3 bytes must insert the new bytes after the initial opcode.