Class TryWithResourcesJavacFilter.Matcher
java.lang.Object
org.jacoco.core.internal.analysis.filter.AbstractMatcher
org.jacoco.core.internal.analysis.filter.TryWithResourcesJavacFilter.Matcher
- Enclosing class:
- TryWithResourcesJavacFilter
javac from JDK 7 and 8 generates bytecode that is equivalent to the
compilation of source code that is described in JLS
14.20.3. try-with-resources:
Resource r = ...; Throwable primaryExc = null; try { ... } finally { if (r != null) { if (primaryExc != null) { try { r.close(); } catch (Throwable suppressedExc) { primaryExc.addSuppressed(suppressedExc); } } else { r.close(); } } }Case of multiple resources looks like multiple nested try-with-resources statements. javac from JDK 9 EA b160 does the same, but with some optimizations (see JDK-7020499):
null
check for resource is omitted when it is initialized usingnew
- synthetic method
$closeResource
containingnull
check of primaryExc and calls to methodsaddSuppressed
andclose
is used when number of copies of closing logic reaches threshold,null
check of resource (if present) is done before call of this method
TryWithResourcesJavacFilter.Matcher.JavacPattern
defines all possible variants that
will be tried sequentially.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private final IFilterOutput
private org.objectweb.asm.tree.AbstractInsnNode
Fields inherited from class org.jacoco.core.internal.analysis.filter.AbstractMatcher
cursor, vars
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
private void
private boolean
On a first invocation will associate variables with names "r" and "primaryExc", on subsequent invocations will use those associations for checks.private void
start
(org.objectweb.asm.tree.AbstractInsnNode start) Methods inherited from class org.jacoco.core.internal.analysis.filter.AbstractMatcher
firstIsALoad0, next, nextIs, nextIsInvoke, nextIsSwitch, nextIsType, nextIsVar, skipNonOpcodes, skipNonOpcodes
-
Field Details
-
output
-
expectedOwner
-
start
private org.objectweb.asm.tree.AbstractInsnNode start
-
-
Constructor Details
-
Matcher
Matcher(IFilterOutput output)
-
-
Method Details
-
start
private void start(org.objectweb.asm.tree.AbstractInsnNode start) -
matchJavac
-
nextIsJavacClose
On a first invocation will associate variables with names "r" and "primaryExc", on subsequent invocations will use those associations for checks. -
nextIsClose
private void nextIsClose()
-