當前位置: 首頁>>代碼示例>>Java>>正文


Java TargetLostException類代碼示例

本文整理匯總了Java中org.apache.bcel.generic.TargetLostException的典型用法代碼示例。如果您正苦於以下問題:Java TargetLostException類的具體用法?Java TargetLostException怎麽用?Java TargetLostException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TargetLostException類屬於org.apache.bcel.generic包,在下文中一共展示了TargetLostException類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteIns

import org.apache.bcel.generic.TargetLostException; //導入依賴的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);
            }
        }
    }
}
 
開發者ID:pieterhijma,項目名稱:cashmere,代碼行數:18,代碼來源:Cashmerec.java

示例2: change1

import org.apache.bcel.generic.TargetLostException; //導入依賴的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;
    }
 
開發者ID:BowlerHatLLC,項目名稱:feathers-sdk,代碼行數:36,代碼來源:Downgrader.java

示例3: change2

import org.apache.bcel.generic.TargetLostException; //導入依賴的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;
}
 
開發者ID:BowlerHatLLC,項目名稱:feathers-sdk,代碼行數:42,代碼來源:Downgrader.java


注:本文中的org.apache.bcel.generic.TargetLostException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。