Package org.jacoco.core.internal.analysis.filter

## Class FinallyFilter

- java.lang.Object
- - org.jacoco.core.internal.analysis.filter.FinallyFilter

All Implemented Interfaces:
  `IFilter`

    public final class FinallyFilter
    extends java.lang.Object
    implements IFilter

Filters duplicates of finally blocks that compiler generates. To understand algorithm of filtering, consider following example:

     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 Summary

Constructors
`FinallyFilter()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `filter​(org.objectweb.asm.tree.MethodNode methodNode, IFilterContext context, IFilterOutput output)` This method is called for every method.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### FinallyFilter

    public FinallyFilter()

### Method Detail

#### filter

    public void filter​(org.objectweb.asm.tree.MethodNode methodNode,
                       IFilterContext context,
                       IFilterOutput output)

Description copied from interface: `IFilter`
This method is called for every method. The filter implementation is expected to inspect the provided method and report its result to the given `IFilterOutput` instance.

Specified by:
  `filter` in interface `IFilter`
Parameters:
  `methodNode` - method to inspect
  `context` - context information for the method
  `output` - callback to report filtering results to