private void createNewBookmarks(List<TryCatchBlock> tryCatchBlocks) { // Add new bookmarks for (int i = tryCatchBookmarks.size(); i < tryCatchBlocks.size(); ++i) { TryCatchBlock tryCatch = tryCatchBlocks.get(tryCatchBlocks.size() - 1 - i); TryCatchBookmark bookmark = new TryCatchBookmark(); bookmark.block = stack.peek(); bookmark.offset = bookmark.block.body.size(); bookmark.exceptionHandler = tryCatch.getHandler().getIndex(); bookmark.exceptionType = tryCatch.getExceptionType(); bookmark.exceptionVariable = tryCatch.getHandler().getExceptionVariable() != null ? tryCatch.getHandler().getExceptionVariable().getIndex() : null; bookmark.block.tryCatches.add(bookmark); tryCatchBookmarks.add(bookmark); } }
public void rename(Program program) { for (int i = 0; i < program.basicBlockCount(); ++i) { BasicBlock basicBlock = program.basicBlockAt(i); for (Instruction insn : basicBlock) { insn.acceptVisitor(this); } for (TryCatchBlock tryCatch : basicBlock.getTryCatchBlocks()) { if (tryCatch.getExceptionType() != null) { tryCatch.setExceptionType(classNameMapper.map(tryCatch.getExceptionType())); } } } }
break; if (!Objects.equals(tryCatch.getExceptionType(), bookmark.exceptionType)) { break;
data.writeInt(tryCatch.getExceptionType() != null ? symbolTable.lookup( tryCatch.getExceptionType()) : -1); data.writeShort(tryCatch.getHandler().getIndex());
public void processMethod(MethodReference method, Program program) { this.methodRef = method; this.program = program; boolean wasModified = false; for (int i = 0; i < program.basicBlockCount(); ++i) { BasicBlock block = program.basicBlockAt(i); instructionsToAdd.clear(); boolean missing = false; for (Instruction insn : block) { insn.acceptVisitor(instructionProcessor); if (!instructionsToAdd.isEmpty()) { wasModified = true; truncateBlock(insn); missing = true; break; } } if (!missing) { for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { checkClass(null, tryCatch.getExceptionType()); } } } if (wasModified) { new UnreachableBasicBlockEliminator().optimize(program); } }
private void propagateException(String thrownTypeName, BasicBlock block) { for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { String expectedType = tryCatch.getExceptionType(); if (expectedType == null || hierarchy.isSuperType(expectedType, thrownTypeName, false)) { if (tryCatch.getHandler().getExceptionVariable() == null) { break; } int exceptionNode = packNodeAndDegree(tryCatch.getHandler().getExceptionVariable().getIndex(), 0); exceptionNode = nodeMapping[exceptionNode]; int thrownType = getTypeByName(thrownTypeName); if (getNodeTypes(exceptionNode).add(thrownType)) { nodeChanged[exceptionNode] = true; changed = true; } break; } } }
for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { ExceptionHandlerDescriptor handler = new ExceptionHandlerDescriptor(++nextHandlerId, tryCatch.getExceptionType()); callSite.getHandlers().add(handler); if (tryCatch.getExceptionType() == null) { defaultExists = true; switchInsn.setDefaultTarget(tryCatch.getHandler());
TryCatchBlock tryCatchCopy = new TryCatchBlock(); int handler = tryCatch.getHandler().getIndex(); tryCatchCopy.setExceptionType(tryCatch.getExceptionType()); tryCatchCopy.setHandler(program.basicBlockAt(copiedNodes.getOrDefault(handler, handler))); targetBlock.getTryCatchBlocks().add(tryCatchCopy);
private void createNewBookmarks(List<TryCatchBlock> tryCatchBlocks) { // Add new bookmarks for (int i = tryCatchBookmarks.size(); i < tryCatchBlocks.size(); ++i) { TryCatchBlock tryCatch = tryCatchBlocks.get(i); TryCatchBookmark bookmark = new TryCatchBookmark(); bookmark.block = stack.peek(); bookmark.offset = bookmark.block.body.size(); bookmark.exceptionHandler = tryCatch.getHandler().getIndex(); bookmark.exceptionType = tryCatch.getExceptionType(); bookmark.exceptionVariable = tryCatch.getHandler().getExceptionVariable() != null ? tryCatch.getHandler().getExceptionVariable().getIndex() : null; bookmark.block.tryCatches.add(bookmark); tryCatchBookmarks.add(bookmark); } }
public void rename(Program program) { for (int i = 0; i < program.basicBlockCount(); ++i) { BasicBlock basicBlock = program.basicBlockAt(i); for (Instruction insn : basicBlock) { insn.acceptVisitor(this); } for (TryCatchBlock tryCatch : basicBlock.getTryCatchBlocks()) { if (tryCatch.getExceptionType() != null) { tryCatch.setExceptionType(classNameMapper.map(tryCatch.getExceptionType())); } } } }
break; if (!Objects.equals(tryCatch.getExceptionType(), bookmark.exceptionType)) { break;
data.writeInt(tryCatch.getExceptionType() != null ? symbolTable.lookup( tryCatch.getExceptionType()) : -1); data.writeShort(tryCatch.getHandler().getIndex());
public void processMethod(MethodHolder method) { this.methodHolder = method; this.program = method.getProgram(); boolean wasModified = false; for (int i = 0; i < program.basicBlockCount(); ++i) { BasicBlock block = program.basicBlockAt(i); instructionsToAdd.clear(); boolean missing = false; for (Instruction insn : block) { insn.acceptVisitor(instructionProcessor); if (!instructionsToAdd.isEmpty()) { wasModified = true; truncateBlock(insn); missing = true; break; } } if (!missing) { for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { checkClass(null, tryCatch.getExceptionType()); } } } if (wasModified) { new UnreachableBasicBlockEliminator().optimize(program); } }
BasicBlock block = program.basicBlockAt(task.variable); for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { if (tryCatch.getExceptionType() == null || classSource.isSuperType(tryCatch.getExceptionType(), task.className).orElse(false)) { Variable exception = tryCatch.getHandler().getExceptionVariable(); if (exception != null) {
for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { ExceptionHandlerDescriptor handler = new ExceptionHandlerDescriptor(++nextHandlerId, tryCatch.getExceptionType()); callSite.getHandlers().add(handler); if (tryCatch.getExceptionType() == null) { defaultExists = true; switchInsn.setDefaultTarget(tryCatch.getHandler());
TryCatchBlock tryCatchCopy = new TryCatchBlock(); int handler = tryCatch.getHandler().getIndex(); tryCatchCopy.setExceptionType(tryCatch.getExceptionType()); tryCatchCopy.setHandler(program.basicBlockAt(copiedNodes.getOrDefault(handler, handler))); targetBlock.getTryCatchBlocks().add(tryCatchCopy);