Class NoAllocationChecker
java.lang.Object
com.google.errorprone.bugpatterns.BugChecker
com.google.errorprone.bugpatterns.NoAllocationChecker
- All Implemented Interfaces:
BugChecker.AssignmentTreeMatcher
,BugChecker.BinaryTreeMatcher
,BugChecker.CompoundAssignmentTreeMatcher
,BugChecker.EnhancedForLoopTreeMatcher
,BugChecker.MethodInvocationTreeMatcher
,BugChecker.MethodTreeMatcher
,BugChecker.NewArrayTreeMatcher
,BugChecker.NewClassTreeMatcher
,BugChecker.ReturnTreeMatcher
,BugChecker.TypeCastTreeMatcher
,BugChecker.UnaryTreeMatcher
,BugChecker.VariableTreeMatcher
,Suppressible
,Serializable
public class NoAllocationChecker
extends BugChecker
implements BugChecker.AssignmentTreeMatcher, BugChecker.BinaryTreeMatcher, BugChecker.CompoundAssignmentTreeMatcher, BugChecker.EnhancedForLoopTreeMatcher, BugChecker.MethodTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.NewArrayTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.TypeCastTreeMatcher, BugChecker.UnaryTreeMatcher, BugChecker.VariableTreeMatcher
Checks methods annotated with
@NoAllocation
to ensure they really do not allocate.
- Calls to new are disallowed.
- Methods statically determined to be reachable from this method must also be annotated with
@NoAllocation
. - Autoboxing is disallowed.
- String concatenation and conversions are disallowed.
- To make it easier to use exceptions, allocations are always allowed within a throw
statement. (But not in the methods of nested classes if they are annotated with
NoAllocation
.) - The check is done at the source level. The compiler or runtime may perform optimizations or transformations that add or remove allocations in a way not visible to this check.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.errorprone.bugpatterns.BugChecker
BugChecker.AnnotatedTypeTreeMatcher, BugChecker.AnnotationTreeMatcher, BugChecker.ArrayAccessTreeMatcher, BugChecker.ArrayTypeTreeMatcher, BugChecker.AssertTreeMatcher, BugChecker.AssignmentTreeMatcher, BugChecker.BinaryTreeMatcher, 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.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.NewArrayTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.ParameterizedTypeTreeMatcher, BugChecker.ParenthesizedTreeMatcher, BugChecker.PrimitiveTypeTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.SuppressibleTreePathScanner<R,
P>, BugChecker.SwitchTreeMatcher, BugChecker.SynchronizedTreeMatcher, BugChecker.ThrowTreeMatcher, BugChecker.TryTreeMatcher, BugChecker.TypeCastTreeMatcher, BugChecker.TypeParameterTreeMatcher, BugChecker.UnaryTreeMatcher, BugChecker.UnionTypeTreeMatcher, BugChecker.VariableTreeMatcher, BugChecker.WhileLoopTreeMatcher, BugChecker.WildcardTreeMatcher -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionmatchAssignment
(com.sun.source.tree.AssignmentTree tree, VisitorState state) matchBinary
(com.sun.source.tree.BinaryTree tree, VisitorState state) matchCompoundAssignment
(com.sun.source.tree.CompoundAssignmentTree tree, VisitorState state) matchEnhancedForLoop
(com.sun.source.tree.EnhancedForLoopTree tree, VisitorState state) matchMethod
(com.sun.source.tree.MethodTree tree, VisitorState state) matchMethodInvocation
(com.sun.source.tree.MethodInvocationTree tree, VisitorState state) matchNewArray
(com.sun.source.tree.NewArrayTree tree, VisitorState state) matchNewClass
(com.sun.source.tree.NewClassTree tree, VisitorState state) matchReturn
(com.sun.source.tree.ReturnTree tree, VisitorState state) matchTypeCast
(com.sun.source.tree.TypeCastTree tree, VisitorState state) matchUnary
(com.sun.source.tree.UnaryTree tree, VisitorState state) matchVariable
(com.sun.source.tree.VariableTree tree, VisitorState state) Methods inherited from class com.google.errorprone.bugpatterns.BugChecker
allNames, buildDescription, buildDescription, buildDescription, canonicalName, customSuppressionAnnotations, defaultSeverity, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, disableable, equals, hashCode, isSuppressed, isSuppressed, isSuppressed, isSuppressed, linkUrl, message, supportsSuppressWarnings, suppressedByAnyOf, suppressedRegions
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.errorprone.matchers.Suppressible
allNames, canonicalName, customSuppressionAnnotations, supportsSuppressWarnings, suppressedByAnyOf
-
Constructor Details
-
NoAllocationChecker
public NoAllocationChecker()
-
-
Method Details
-
matchNewArray
- Specified by:
matchNewArray
in interfaceBugChecker.NewArrayTreeMatcher
-
matchNewClass
- Specified by:
matchNewClass
in interfaceBugChecker.NewClassTreeMatcher
-
matchMethodInvocation
public Description matchMethodInvocation(com.sun.source.tree.MethodInvocationTree tree, VisitorState state) - Specified by:
matchMethodInvocation
in interfaceBugChecker.MethodInvocationTreeMatcher
-
matchMethod
- Specified by:
matchMethod
in interfaceBugChecker.MethodTreeMatcher
-
matchBinary
- Specified by:
matchBinary
in interfaceBugChecker.BinaryTreeMatcher
-
matchCompoundAssignment
public Description matchCompoundAssignment(com.sun.source.tree.CompoundAssignmentTree tree, VisitorState state) - Specified by:
matchCompoundAssignment
in interfaceBugChecker.CompoundAssignmentTreeMatcher
-
matchEnhancedForLoop
public Description matchEnhancedForLoop(com.sun.source.tree.EnhancedForLoopTree tree, VisitorState state) - Specified by:
matchEnhancedForLoop
in interfaceBugChecker.EnhancedForLoopTreeMatcher
-
matchAssignment
- Specified by:
matchAssignment
in interfaceBugChecker.AssignmentTreeMatcher
-
matchVariable
- Specified by:
matchVariable
in interfaceBugChecker.VariableTreeMatcher
-
matchTypeCast
- Specified by:
matchTypeCast
in interfaceBugChecker.TypeCastTreeMatcher
-
matchReturn
- Specified by:
matchReturn
in interfaceBugChecker.ReturnTreeMatcher
-
matchUnary
- Specified by:
matchUnary
in interfaceBugChecker.UnaryTreeMatcher
-