Class Finally
java.lang.Object
com.google.errorprone.bugpatterns.BugChecker
com.google.errorprone.bugpatterns.Finally
- All Implemented Interfaces:
BugChecker.BreakTreeMatcher, BugChecker.ContinueTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.ThrowTreeMatcher, Suppressible, Serializable
public class Finally
extends BugChecker
implements BugChecker.ContinueTreeMatcher, BugChecker.ThrowTreeMatcher, BugChecker.BreakTreeMatcher, BugChecker.ReturnTreeMatcher
Matches the behaviour of javac's finally Xlint warning.
1) Any return statement in a finally block is an error 2) An uncaught throw statement in a finally block is an error. We can't always know whether a specific exception will be caught, so we report errors for throw statements that are not contained in a try with at least one catch block. 3) A continue statement in a finally block is an error if it breaks out of a (possibly labeled) loop that is outside the enclosing finally. 4) A break statement in a finally block is an error if it breaks out of a (possibly labeled) loop or a switch statement that is outside the enclosing finally.
- Author:
- eaftan@google.com (Eddie Aftandilian), cushon@google.com (Liam Miller-Cushon)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class BugChecker
BugChecker.AnnotatedTypeTreeMatcher, BugChecker.AnnotationTreeMatcher, BugChecker.ArrayAccessTreeMatcher, BugChecker.ArrayTypeTreeMatcher, BugChecker.AssertTreeMatcher, BugChecker.AssignmentTreeMatcher, BugChecker.BinaryTreeMatcher, BugChecker.BindingPatternTreeMatcher, BugChecker.BlockTreeMatcher, BugChecker.BreakTreeMatcher, BugChecker.CaseTreeMatcher, BugChecker.CatchTreeMatcher, BugChecker.ClassTreeMatcher, BugChecker.CompilationUnitTreeMatcher, BugChecker.CompoundAssignmentTreeMatcher, BugChecker.ConditionalExpressionTreeMatcher, BugChecker.ContinueTreeMatcher, BugChecker.DoWhileLoopTreeMatcher, BugChecker.EmptyStatementTreeMatcher, BugChecker.EnhancedForLoopTreeMatcher, BugChecker.ExportsTreeMatcher, BugChecker.ExpressionStatementTreeMatcher, BugChecker.ForLoopTreeMatcher, BugChecker.IdentifierTreeMatcher, BugChecker.IfTreeMatcher, BugChecker.ImportTreeMatcher, BugChecker.InstanceOfTreeMatcher, BugChecker.IntersectionTypeTreeMatcher, BugChecker.LabeledStatementTreeMatcher, BugChecker.LambdaExpressionTreeMatcher, BugChecker.LiteralTreeMatcher, BugChecker.MemberReferenceTreeMatcher, BugChecker.MemberSelectTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.MethodTreeMatcher, BugChecker.ModifiersTreeMatcher, BugChecker.ModuleTreeMatcher, BugChecker.NewArrayTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.OpensTreeMatcher, BugChecker.PackageTreeMatcher, BugChecker.ParameterizedTypeTreeMatcher, BugChecker.ParenthesizedTreeMatcher, BugChecker.PrimitiveTypeTreeMatcher, BugChecker.ProvidesTreeMatcher, BugChecker.RequiresTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.SuppressibleTreePathScanner<R,P>, BugChecker.SwitchExpressionTreeMatcher, BugChecker.SwitchTreeMatcher, BugChecker.SynchronizedTreeMatcher, BugChecker.ThrowTreeMatcher, BugChecker.TryTreeMatcher, BugChecker.TypeCastTreeMatcher, BugChecker.TypeParameterTreeMatcher, BugChecker.UnaryTreeMatcher, BugChecker.UnionTypeTreeMatcher, BugChecker.UsesTreeMatcher, BugChecker.VariableTreeMatcher, BugChecker.WhileLoopTreeMatcher, BugChecker.WildcardTreeMatcher, BugChecker.YieldTreeMatcher -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionmatchBreak(BreakTree tree, VisitorState state) matchContinue(ContinueTree tree, VisitorState state) matchReturn(ReturnTree tree, VisitorState state) matchThrow(ThrowTree tree, VisitorState state) Methods inherited from class BugChecker
allNames, buildDescription, buildDescription, buildDescription, canonicalName, customSuppressionAnnotations, defaultSeverity, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, disableable, equals, hashCode, isSuppressed, isSuppressed, linkUrl, message, supportsSuppressWarnings, suppressedByAnyOf, suppressedRegionsMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Suppressible
allNames, canonicalName, customSuppressionAnnotations, supportsSuppressWarnings, suppressedByAnyOf
-
Constructor Details
-
Finally
public Finally()
-
-
Method Details
-
matchContinue
- Specified by:
matchContinuein interfaceBugChecker.ContinueTreeMatcher
-
matchBreak
- Specified by:
matchBreakin interfaceBugChecker.BreakTreeMatcher
-
matchThrow
- Specified by:
matchThrowin interfaceBugChecker.ThrowTreeMatcher
-
matchReturn
- Specified by:
matchReturnin interfaceBugChecker.ReturnTreeMatcher
-