use of jadx.core.dex.trycatch.CatchAttr in project jadx by skylot.
the class BlockExceptionHandler method processExceptionHandlers.
private static void processExceptionHandlers(MethodNode mth, BlockNode block) {
ExcHandlerAttr handlerAttr = block.get(AType.EXC_HANDLER);
if (handlerAttr == null) {
return;
}
ExceptionHandler excHandler = handlerAttr.getHandler();
excHandler.addBlock(block);
for (BlockNode node : BlockUtils.collectBlocksDominatedBy(block, block)) {
excHandler.addBlock(node);
}
for (BlockNode excBlock : excHandler.getBlocks()) {
// remove 'monitor-exit' from exception handler blocks
InstructionRemover remover = new InstructionRemover(mth, excBlock);
for (InsnNode insn : excBlock.getInstructions()) {
if (insn.getType() == InsnType.MONITOR_ENTER) {
break;
}
if (insn.getType() == InsnType.MONITOR_EXIT) {
remover.add(insn);
}
}
remover.perform();
// if 'throw' in exception handler block have 'catch' - merge these catch blocks
for (InsnNode insn : excBlock.getInstructions()) {
CatchAttr catchAttr = insn.get(AType.CATCH_BLOCK);
if (catchAttr == null) {
continue;
}
if (insn.getType() == InsnType.THROW || onlyAllHandler(catchAttr.getTryBlock())) {
TryCatchBlock handlerBlock = handlerAttr.getTryBlock();
TryCatchBlock catchBlock = catchAttr.getTryBlock();
handlerBlock.merge(mth, catchBlock);
}
}
}
}
use of jadx.core.dex.trycatch.CatchAttr in project jadx by skylot.
the class BlockFinallyExtract method markForRemove.
/**
* Unbind block for removing.
*/
private static void markForRemove(MethodNode mth, BlockNode block) {
for (BlockNode p : block.getPredecessors()) {
p.getSuccessors().remove(block);
p.updateCleanSuccessors();
}
for (BlockNode s : block.getSuccessors()) {
s.getPredecessors().remove(block);
}
block.getPredecessors().clear();
block.getSuccessors().clear();
block.add(AFlag.REMOVE);
block.remove(AFlag.SKIP);
CatchAttr catchAttr = block.get(AType.CATCH_BLOCK);
if (catchAttr != null) {
catchAttr.getTryBlock().removeBlock(mth, block);
for (BlockNode skipBlock : mth.getBasicBlocks()) {
if (skipBlock.contains(AFlag.SKIP)) {
markForRemove(mth, skipBlock);
}
}
}
}
Aggregations