当前位置: 首页>>代码示例>>Java>>正文


Java TryBlock.getExceptionHandlers方法代码示例

本文整理汇总了Java中org.jf.dexlib2.iface.TryBlock.getExceptionHandlers方法的典型用法代码示例。如果您正苦于以下问题:Java TryBlock.getExceptionHandlers方法的具体用法?Java TryBlock.getExceptionHandlers怎么用?Java TryBlock.getExceptionHandlers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jf.dexlib2.iface.TryBlock的用法示例。


在下文中一共展示了TryBlock.getExceptionHandlers方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: usedTypes

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
/**
 * Return the types that are used in this body.
 */
public Set<Type> usedTypes() {
    Set<Type> types = new HashSet<Type>();
    for (DexlibAbstractInstruction i : instructions)
        types.addAll(i.introducedTypes());

    if(tries!=null) {
     for (TryBlock<? extends ExceptionHandler> tryItem : tries) {
         List<? extends ExceptionHandler> hList = tryItem.getExceptionHandlers();
      for (ExceptionHandler handler: hList) {
          String exType = handler.getExceptionType();
          if (exType == null) // for handler which capture all Exceptions
              continue;
          types.add(DexType.toSoot(exType));
      }
     }
    }

    return types;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:23,代码来源:DexBody.java

示例2: of

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
public static ImmutableTryBlock of(TryBlock<? extends ExceptionHandler> tryBlock) {
    if (tryBlock instanceof ImmutableTryBlock) {
        return (ImmutableTryBlock)tryBlock;
    }
    return new ImmutableTryBlock(
            tryBlock.getStartCodeAddress(),
            tryBlock.getCodeUnitCount(),
            tryBlock.getExceptionHandlers());
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:10,代码来源:ImmutableTryBlock.java

示例3: massageTryBlocks

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
public static <EH extends ExceptionHandler> List<TryBlock<EH>> massageTryBlocks(
        List<? extends TryBlock<? extends EH>> tryBlocks) {
    TryListBuilder<EH> tlb = new TryListBuilder<EH>();

    for (TryBlock<? extends EH> tryBlock: tryBlocks) {
        int startAddress = tryBlock.getStartCodeAddress();
        int endAddress = startAddress + tryBlock.getCodeUnitCount();

        for (EH exceptionHandler: tryBlock.getExceptionHandlers()) {
            tlb.addHandler(startAddress, endAddress, exceptionHandler);
        }
    }
    return tlb.getTryBlocks();
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:15,代码来源:TryListBuilder.java

示例4: of

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
public static ImmutableTryBlock of(TryBlock<? extends ExceptionHandler> tryBlock) {
    if (tryBlock instanceof ImmutableTryBlock) {
        return (ImmutableTryBlock) tryBlock;
    }
    return new ImmutableTryBlock(
            tryBlock.getStartCodeAddress(),
            tryBlock.getCodeUnitCount(),
            tryBlock.getExceptionHandlers());
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:10,代码来源:ImmutableTryBlock.java

示例5: massageTryBlocks

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
public static <EH extends ExceptionHandler> List<TryBlock<EH>> massageTryBlocks(
        List<? extends TryBlock<? extends EH>> tryBlocks) {
    TryListBuilder<EH> tlb = new TryListBuilder<EH>();

    for (TryBlock<? extends EH> tryBlock : tryBlocks) {
        int startAddress = tryBlock.getStartCodeAddress();
        int endAddress = startAddress + tryBlock.getCodeUnitCount();

        for (EH exceptionHandler : tryBlock.getExceptionHandlers()) {
            tlb.addHandler(startAddress, endAddress, exceptionHandler);
        }
    }
    return tlb.getTryBlocks();
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:15,代码来源:TryListBuilder.java

示例6: buildExceptionHandlerArray

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
@Nonnull
private AnalyzedInstruction[] buildExceptionHandlerArray(@Nonnull TryBlock<? extends ExceptionHandler> tryBlock) {
    List<? extends ExceptionHandler> exceptionHandlers = tryBlock.getExceptionHandlers();

    AnalyzedInstruction[] handlerInstructions = new AnalyzedInstruction[exceptionHandlers.size()];
    for (int i = 0; i < exceptionHandlers.size(); i++) {
        handlerInstructions[i] = analyzedInstructions.get(exceptionHandlers.get(i).getHandlerCodeAddress());
    }

    return handlerInstructions;
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:12,代码来源:MethodAnalyzer.java

示例7: analyzeMoveException

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
private void analyzeMoveException(@Nonnull AnalyzedInstruction analyzedInstruction) {
    int instructionAddress = getInstructionAddress(analyzedInstruction);

    RegisterType exceptionType = RegisterType.UNKNOWN_TYPE;

    for (TryBlock<? extends ExceptionHandler> tryBlock : methodImpl.getTryBlocks()) {
        for (ExceptionHandler handler : tryBlock.getExceptionHandlers()) {

            if (handler.getHandlerCodeAddress() == instructionAddress) {
                String type = handler.getExceptionType();
                if (type == null) {
                    exceptionType = RegisterType.getRegisterType(RegisterType.REFERENCE,
                            classPath.getClass("Ljava/lang/Throwable;"));
                } else {
                    exceptionType = RegisterType.getRegisterType(RegisterType.REFERENCE, classPath.getClass(type))
                            .merge(exceptionType);
                }
            }
        }
    }

    if (exceptionType.category == RegisterType.UNKNOWN) {
        throw new AnalysisException("move-exception must be the first instruction in an exception handler block");
    }

    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, exceptionType);
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:28,代码来源:MethodAnalyzer.java

示例8: addTraps

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
/**
  * Add the traps of this body.
  *
  * Should only be called at the end jimplify.
  */
 private void addTraps() {
   for (TryBlock<? extends ExceptionHandler> tryItem : tries) {
         int startAddress = tryItem.getStartCodeAddress();
         Debug.printDbg(" start : 0x", Integer.toHexString(startAddress));
         int length = tryItem.getCodeUnitCount();//.getTryLength();
         Debug.printDbg(" length: 0x", Integer.toHexString(length));
         Debug.printDbg(" end   : 0x", Integer.toHexString(startAddress + length));
         int endAddress = startAddress + length;// - 1;
         Unit beginStmt = instructionAtAddress(startAddress).getUnit();
         // (startAddress + length) typically points to the first byte of the first instruction after the try block
         // except if there is no instruction after the try block in which case it points to the last byte of the last
         // instruction of the try block. Removing 1 from (startAddress + length) always points to "somewhere" in
         // the last instruction of the try block since the smallest instruction is on two bytes (nop = 0x0000).
         Unit endStmt =  instructionAtAddress (endAddress).getUnit();
// if the try block ends on the last instruction of the body, add a
// nop instruction so Soot can include
// the last instruction in the try block.
if (jBody.getUnits().getLast() == endStmt
		&& instructionAtAddress(endAddress - 1).getUnit() == endStmt) {
	Unit nop = Jimple.v().newNopStmt();
	jBody.getUnits().insertAfter(nop, endStmt);
	endStmt = nop;
}
Debug.printDbg("begin instruction (0x",
		Integer.toHexString(startAddress), "): ",
		instructionAtAddress(startAddress).getUnit(), " --- ",
		beginStmt);
Debug.printDbg("end instruction   (0x",
		Integer.toHexString(endAddress), "): ",
		instructionAtAddress(endAddress).getUnit(), " --- ",
		endStmt);


         List<? extends ExceptionHandler> hList = tryItem.getExceptionHandlers();
         for (ExceptionHandler handler: hList) {
           int handlerAddress = handler.getHandlerCodeAddress();
           Debug.printDbg("handler   (0x",
         		  Integer.toHexString(handlerAddress),
         		  "): ",
         		  instructionAtAddress (handlerAddress).getUnit(),
         		  " --- ",
         		  handlerAddress > 0 ? instructionAtAddress (handlerAddress-1).getUnit() : "<unknown>");
           String exceptionType = handler.getExceptionType();
           if (exceptionType == null)
               exceptionType = "Ljava/lang/Throwable;";
           Type t = DexType.toSoot(exceptionType);
             // exceptions can only be of RefType
             if (t instanceof RefType) {
                 SootClass exception = ((RefType) t).getSootClass();
                 DexlibAbstractInstruction instruction = instructionAtAddress(handler.getHandlerCodeAddress());
                 if (! (instruction instanceof MoveExceptionInstruction))
                     Debug.printDbg("First instruction of trap handler unit not MoveException but " , instruction.getClass());
                 else
                   ((MoveExceptionInstruction) instruction).setRealType(this, exception.getType());

                 Trap trap = Jimple.v().newTrap(exception, beginStmt, endStmt, instruction.getUnit());
                 jBody.getTraps().add(trap);
             }
         }
     }
 }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:67,代码来源:DexBody.java

示例9: internCode

import org.jf.dexlib2.iface.TryBlock; //导入方法依赖的package包/类
private void internCode(@Nonnull Method method) {
    // this also handles parameter names, which aren't directly tied to the MethodImplementation, even though the debug items are
    boolean hasInstruction = false;

    MethodImplementation methodImpl = method.getImplementation();
    if (methodImpl != null) {
        for (Instruction instruction : methodImpl.getInstructions()) {
            hasInstruction = true;
            if (instruction instanceof ReferenceInstruction) {
                Reference reference = ((ReferenceInstruction) instruction).getReference();
                switch (instruction.getOpcode().referenceType) {
                    case ReferenceType.STRING:
                        stringPool.intern((StringReference) reference);
                        break;
                    case ReferenceType.TYPE:
                        typePool.intern((TypeReference) reference);
                        break;
                    case ReferenceType.FIELD:
                        fieldPool.intern((FieldReference) reference);
                        break;
                    case ReferenceType.METHOD:
                        methodPool.intern((MethodReference) reference);
                        break;
                    default:
                        throw new ExceptionWithContext("Unrecognized reference type: %d",
                                instruction.getOpcode().referenceType);
                }
            }
        }

        List<? extends TryBlock> tryBlocks = methodImpl.getTryBlocks();
        if (!hasInstruction && tryBlocks.size() > 0) {
            throw new ExceptionWithContext("Method %s has no instructions, but has try blocks.",
                    ReferenceUtil.getMethodDescriptor(method));
        }

        for (TryBlock<? extends ExceptionHandler> tryBlock : methodImpl.getTryBlocks()) {
            for (ExceptionHandler handler : tryBlock.getExceptionHandlers()) {
                typePool.internNullable(handler.getExceptionType());
            }
        }
    }
}
 
开发者ID:niranjan94,项目名称:show-java,代码行数:44,代码来源:ClassPool.java


注:本文中的org.jf.dexlib2.iface.TryBlock.getExceptionHandlers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。