Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of org.apache.bcel.generic.BranchInstruction

    public void redirectBranches(final InstructionHandle old_target, final InstructionHandle new_target) {

for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {

final Instruction i = ih.getInstruction();

if (i instanceof BranchInstruction) {

final BranchInstruction b = (BranchInstruction) i;

final InstructionHandle target = b.getTarget();

if (target == old_target) {

b.setTarget(new_target);

}

if (b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH

final InstructionHandle[] targets = ((Select) b).getTargets();

for (int j = 0; j < targets.length; j++) {

if (targets[j] == old_target) {

((Select) b).setTarget(j, new_target);

}

}

}

}

}

}


   Like      Feedback      org.apache.bcel.generic.BranchInstruction



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner