@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; }
/** * 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) { // Exceptions continue; } types.add(DexType.toSoot(exType)); } } } return types; }
private String[] buildExceptions(Method method) { if (method.getImplementation() == null) { return null; } Set<String> exceptionTypes = new HashSet<>(); for (TryBlock<? extends ExceptionHandler> tryBlock : method.getImplementation() .getTryBlocks()) { for (ExceptionHandler handler : tryBlock.getExceptionHandlers()) { String type = handler.getExceptionType(); if (type == null) { // Type is null if it's a catchall continue; } exceptionTypes.add(stripName(type)); } } return exceptionTypes.toArray(new String[0]); }
int lastCoveredAddress = instructionOffsetMap.getInstructionCodeOffset(lastCoveredIndex); for (ExceptionHandler handler: tryBlock.getExceptionHandlers()) { int handlerAddress = handler.getHandlerCodeAddress(); if (handlerAddress >= codeSize) {
List<? extends ExceptionHandler> handlers = tryBlock.getExceptionHandlers(); if (catchAll) {
Label endLabel = newLabel(codeAddressToIndex, tryBlock.getStartCodeAddress() + tryBlock.getCodeUnitCount()); for (ExceptionHandler exceptionHandler : tryBlock.getExceptionHandlers()) { tryBlocks.add(new BuilderTryBlock(startLabel, endLabel, (TypeReference) convertReference(exceptionHandler.getExceptionTypeReference()),
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); }
for (ExceptionHandler handler: tryBlock.getExceptionHandlers()) { dexPool.typeSection.internNullable(handler.getExceptionType());
exceptionHandlerOffsetMap.put(tryBlock.getExceptionHandlers(), 0); writer.writeUshort(tbCodeUnitCount); if (tryBlock.getExceptionHandlers().size() == 0) { throw new ExceptionWithContext("No exception handlers for the try block!"); Integer offset = exceptionHandlerOffsetMap.get(tryBlock.getExceptionHandlers()); if (offset != 0) { exceptionHandlerOffsetMap.put(tryBlock.getExceptionHandlers(), offset); int ehSize = tryBlock.getExceptionHandlers().size(); ExceptionHandler ehLast = tryBlock.getExceptionHandlers().get(ehSize-1); if (ehLast.getExceptionType() == null) { ehSize = ehSize * (-1) + 1; for (ExceptionHandler eh : tryBlock.getExceptionHandlers()) { TypeKey exceptionTypeKey = classSection.getExceptionType(eh);
List<? extends ExceptionHandler> hList = tryItem.getExceptionHandlers(); for (ExceptionHandler handler : hList) { String exceptionType = handler.getExceptionType();
@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; }
@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; }
public static ImmutableTryBlock of(TryBlock<? extends ExceptionHandler> tryBlock) { if (tryBlock instanceof ImmutableTryBlock) { return (ImmutableTryBlock)tryBlock; } return new ImmutableTryBlock( tryBlock.getStartCodeAddress(), tryBlock.getCodeUnitCount(), tryBlock.getExceptionHandlers()); }
public static ImmutableTryBlock of(TryBlock<? extends ExceptionHandler> tryBlock) { if (tryBlock instanceof ImmutableTryBlock) { return (ImmutableTryBlock)tryBlock; } return new ImmutableTryBlock( tryBlock.getStartCodeAddress(), tryBlock.getCodeUnitCount(), tryBlock.getExceptionHandlers()); }
public static ImmutableTryBlock of(TryBlock<? extends ExceptionHandler> tryBlock) { if (tryBlock instanceof ImmutableTryBlock) { return (ImmutableTryBlock)tryBlock; } return new ImmutableTryBlock( tryBlock.getStartCodeAddress(), tryBlock.getCodeUnitCount(), tryBlock.getExceptionHandlers()); }
@Override public boolean equals(Object o) { if (o instanceof TryBlock) { TryBlock other = (TryBlock)o; return getStartCodeAddress() == other.getStartCodeAddress() && getCodeUnitCount() == other.getCodeUnitCount() && getExceptionHandlers().equals(other.getExceptionHandlers()); } return false; } }
@Override public boolean equals(Object o) { if (o instanceof TryBlock) { TryBlock other = (TryBlock)o; return getStartCodeAddress() == other.getStartCodeAddress() && getCodeUnitCount() == other.getCodeUnitCount() && getExceptionHandlers().equals(other.getExceptionHandlers()); } return false; } }
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(); }
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(); }
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(); }