IFilter
public final class FinallyFilter extends java.lang.Object implements IFilter
try { if (x) { a(); return; // 1 } b(); // 2 } catch (Exception e) { c(); // 3 } finally { d(); // 4 }There are 4 distinct points of exit out of these "try/catch/finally" blocks - three without exception, and one with Throwable if it is thrown prior to reaching first three points of exit. "finally" block must be executed just before these points, so there must be 4 copies of its bytecode instructions. One of them handles Throwable ("catch-any") and must cover all instructions of "try/catch" blocks. But must not cover instructions of other duplicates, because instructions of "finally" block also can cause Throwable to be thrown. Therefore there will be multiple
MethodNode.tryCatchBlocks
with
TryCatchBlockNode.type
null with same
TryCatchBlockNode.handler
for different non-intersecting bytecode
regions (TryCatchBlockNode.start
, TryCatchBlockNode.end
).
And each exit out of these regions, except one that handles Throwable, will
contain duplicate of "finally" block.
To determine exits out of these regions, they all must be processed together
at once, because execution can branch from one region to another (like it is
in given example due to "if" statement).Constructor | Description |
---|---|
FinallyFilter() |
Modifier and Type | Method | Description |
---|---|---|
void |
filter(java.lang.String className,
java.lang.String superClassName,
org.objectweb.asm.tree.MethodNode methodNode,
IFilterOutput output) |
This method is called for every method.
|
public void filter(java.lang.String className, java.lang.String superClassName, org.objectweb.asm.tree.MethodNode methodNode, IFilterOutput output)
IFilter
IFilterOutput
instance.Copyright © 2018. All rights reserved.