Buggy code:
final class ShadowRange extends Range { private BcelShadow shadow ; public ShadowRange ( InstructionList body ) { } protected void associateWithTargets ( InstructionHandle start , InstructionHandle end ) { } public void associateWithShadow ( BcelShadow shadow ) { } public Kind getKind ( ) { } public String toString ( ) { } void extractInstructionsInto ( LazyMethodGen freshMethod , IntMap remap , boolean addReturn ) { LazyMethodGen . assertGoodBody ( getBody ( ) , toString ( ) ) ; freshMethod . assertGoodBody ( ) ; InstructionList freshBody = freshMethod . getBody ( ) ; for ( InstructionHandle oldIh = start . getNext ( ) ; oldIh != ( end ) ; oldIh = oldIh . getNext ( ) ) { Instruction oldI = oldIh . getInstruction ( ) ; <START_BUG> Instruction freshI = ( oldI == ( RANGEINSTRUCTION ) ) ? oldI : oldI . copy ( ) ; <END_BUG> InstructionHandle freshIh ; if ( freshI instanceof BranchInstruction ) { BranchInstruction oldBranch = ( ( BranchInstruction ) ( oldI ) ) ; BranchInstruction freshBranch = ( ( BranchInstruction ) ( freshI ) ) ; InstructionHandle oldTarget = oldBranch . getTarget ( ) ; oldTarget . removeTargeter ( oldBranch ) ; oldTarget . addTargeter ( freshBranch ) ; if ( freshBranch instanceof Select ) { Select oldSelect = ( ( Select ) ( oldI ) ) ; Select freshSelect = ( ( Select ) ( freshI ) ) ; InstructionHandle [ ] oldTargets = freshSelect . getTargets ( ) ; for ( int k = ( oldTargets . length ) - 1 ; k >= 0 ; k -- ) { oldTargets [ k ] . removeTargeter ( oldSelect ) ; oldTargets [ k ] . addTargeter ( freshSelect ) ; } } freshIh = freshBody . append ( freshBranch ) ; } else { freshIh = freshBody . append ( freshI ) ; } InstructionTargeter [ ] sources = oldIh . getTargeters ( ) ; if ( sources != null ) { for ( int j = ( sources . length ) - 1 ; j >= 0 ; j -- ) { InstructionTargeter source = sources [ j ] ; if ( source instanceof LocalVariableTag ) { source . updateTarget ( oldIh , null ) ; } else if ( source instanceof Range ) { ( ( Range ) ( source ) ) . updateTarget ( oldIh , freshIh , freshBody ) ; } else { source . updateTarget ( oldIh , freshIh ) ; } } } if ( ( freshI instanceof LocalVariableInstruction ) || ( freshI instanceof RET ) ) { IndexedInstruction indexedI = ( ( IndexedInstruction ) ( freshI ) ) ; int oldIndex = indexedI . getIndex ( ) ; int freshIndex ; if ( ! ( remap . hasKey ( oldIndex ) ) ) { freshIndex = freshMethod . allocateLocal ( 2 ) ; remap . put ( oldIndex , freshIndex ) ; } else { freshIndex = remap . get ( oldIndex ) ; } indexedI . setIndex ( freshIndex ) ; } } try { for ( InstructionHandle oldIh = start . getNext ( ) ; oldIh != ( end ) ; ) { InstructionHandle next = oldIh . getNext ( ) ; body . delete ( oldIh ) ; oldIh = next ; } } catch ( TargetLostException e ) { throw new BCException ( "shouldn't<seq2seq4repair_space>have<seq2seq4repair_space>gotten<seq2seq4repair_space>a<seq2seq4repair_space>target<seq2seq4repair_space>lost" ) ; } InstructionHandle ret = null ; if ( addReturn ) { ret = freshBody . append ( new org . apache . bcel . generic . InstructionFactory ( freshMethod . getEnclosingClass ( ) . getConstantPoolGen ( ) ) . createReturn ( freshMethod . getReturnType ( ) ) ) ; } InstructionTargeter [ ] ts = end . getTargeters ( ) ; if ( ts != null ) { for ( int j = ( ts . length ) - 1 ; j >= 0 ; j -- ) { InstructionTargeter t = ts [ j ] ; if ( t == ( this ) ) continue ; if ( ! addReturn ) { throw new BCException ( "range<seq2seq4repair_space>has<seq2seq4repair_space>target,<seq2seq4repair_space>but<seq2seq4repair_space>we<seq2seq4repair_space>aren't<seq2seq4repair_space>adding<seq2seq4repair_space>a<seq2seq4repair_space>return" ) ; } else { t . updateTarget ( end , ret ) ; } } } LazyMethodGen . assertGoodBody ( getBody ( ) , toString ( ) ) ; freshMethod . assertGoodBody ( ) ; } public BcelShadow getShadow ( ) { } }

Fix:
Instruction freshI = ( oldI == ( RANGEINSTRUCTION ) ) ? oldI : Utility . copyInstruction ( oldI ) ;