本文整理汇总了Java中org.apache.bcel.generic.InstructionList.delete方法的典型用法代码示例。如果您正苦于以下问题:Java InstructionList.delete方法的具体用法?Java InstructionList.delete怎么用?Java InstructionList.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.generic.InstructionList
的用法示例。
在下文中一共展示了InstructionList.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteIns
import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
static private void deleteIns(InstructionList il, InstructionHandle ih,
InstructionHandle new_target) {
// System.out.println("deleteIns: instructionList = " + il);
// System.out.println(" handle = " + ih);
try {
il.delete(ih);
} catch (TargetLostException e) {
InstructionHandle[] targets = e.getTargets();
for (int i = 0; i < targets.length; i++) {
InstructionTargeter[] targeters = targets[i].getTargeters();
for (int j = 0; j < targeters.length; j++) {
targeters[j].updateTarget(targets[i], new_target);
}
}
}
}
示例2: change1
import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
private boolean change1(MethodGen mg)
{
InstructionList il = mg.getInstructionList();
InstructionFinder f = new InstructionFinder(il);
String pat = "[LDC_W|LDC] INVOKEVIRTUAL IFNE ICONST_1 GOTO ICONST_0";
boolean changed = false;
for(Iterator j = f.search(pat, new IsLdcClass()); j.hasNext(); )
{
InstructionHandle[] match = (InstructionHandle[]) j.next();
// replace
// LDC_W <class>
// INVOKEVIRTUAL Class.desiredAssertionStatus
// IFNE
// ICONST_1
// goto
// ICONST_0
// with
// ICONST_1
changed = true;
match[0].setInstruction(InstructionConstants.ICONST_1);
try
{
il.delete(match[1], match[5]);
// System.out.println(il);
}
catch (TargetLostException e)
{
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
return changed;
}
示例3: change2
import org.apache.bcel.generic.InstructionList; //导入方法依赖的package包/类
private boolean change2(MethodGen mg)
{
InstructionList il = mg.getInstructionList();
InstructionFinder f = new InstructionFinder(il);
String pat = "ALOAD_0 ALOAD_1 PUTFIELD ALOAD_0 INVOKESPECIAL";
boolean changed = false;
for(Iterator j = f.search(pat, new IsInnerConstructor()); j.hasNext(); )
{
InstructionHandle[] match = (InstructionHandle[]) j.next();
// replace
// ALOAD_0 [0]
// ALOAD_1 [1]
// PUTFIELD [2]
// ALOAD_0 [3]
// INVOKESPECIAL [4]
// with
// ALOAD_0 [0]
// INVOKESPECIAL [4]
// ALOAD_0 [3]
// ALOAD_1 [1]
// PUTFIELD [2]
changed = true;
try
{
InstructionList il2 = new InstructionList();
il2.append(match[3].getInstruction());
il2.append(match[4].getInstruction());
il.delete(match[3], match[4]);
il.insert(match[0], il2);
}
catch (TargetLostException e)
{
System.err.println("ERROR IN "+mg);
e.printStackTrace();
}
}
return changed;
}