|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.source.util.TreeScanner<R,P> com.sun.source.util.TreePathScanner<R,P> checkers.source.SourceVisitor<R,P> checkers.basetype.BaseTypeVisitor<Void,Void> checkers.nullness.NullnessVisitor
public class NullnessVisitor
A type-checking visitor for the Nullness type system.
This visitor reports errors ("dereference.of.nullable") or
warnings for violations for the following cases:
1. if the receiver of a member dereference is not NonNull
2. if the receiver of an implicit ".iterator()" dereference in an enhanced
for loop is not NonNull
3. if an accessed array is not NonNull
4. if a thrown exception is not NonNull
5. if the lock in a synchronized block is not NonNull
6. if a NonNull reference is checked for nullness
7. if a value in implicit unboxed operation is not NonNull
Self-accesses (via this
or super
) can always be dereferenced.
NullnessChecker
Field Summary |
---|
Fields inherited from class checkers.basetype.BaseTypeVisitor |
---|
annoFactory, annoTypes, checker, visitorState |
Fields inherited from class checkers.source.SourceVisitor |
---|
atypeFactory, elements, root, trees, types |
Constructor Summary | |
---|---|
NullnessVisitor(NullnessChecker checker,
CompilationUnitTree root)
Creates a new visitor for type-checking NonNull . |
Method Summary | |
---|---|
protected boolean |
checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method,
MethodInvocationTree node)
Special casing NonNull and Raw method calls |
Void |
visitArrayAccess(ArrayAccessTree node,
Void p)
Case 3: Check for array dereferencing |
Void |
visitAssignment(AssignmentTree node,
Void p)
Performs two checks: subtyping and assignability checks, using BaseTypeVisitor.commonAssignmentCheck(Tree, ExpressionTree, String, Object) . |
Void |
visitBinary(BinaryTree node,
Void p)
Case 6: Check for redundant nullness tests Case 7: unboxing case: primitive operations |
Void |
visitCompoundAssignment(CompoundAssignmentTree node,
Void p)
Case 7: unboxing case: primitive operation |
Void |
visitEnhancedForLoop(EnhancedForLoopTree node,
Void p)
Case 2: Check for implicit .iterator call |
Void |
visitMemberSelect(MemberSelectTree node,
Void p)
Case 1: Check for null dereferecing |
Void |
visitMethod(MethodTree node,
Void p)
Performs pseudo-assignment check: checks that the method obeys override and subtype rules to all overridden methods. |
Void |
visitSynchronized(SynchronizedTree node,
Void p)
Case 5: Check for synchronizing locks |
Void |
visitThrow(ThrowTree node,
Void p)
Case 4: Check for thrown exception nullness |
Void |
visitTypeCast(TypeCastTree node,
Void p)
Case 7: unboxing case: casting to a primitive |
Void |
visitUnary(UnaryTree node,
Void p)
Case 7: unboxing case: primitive operation |
Methods inherited from class com.sun.source.util.TreePathScanner |
---|
getCurrentPath, scan |
Methods inherited from class com.sun.source.util.TreeScanner |
---|
reduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBlock, visitBreak, visitCase, visitCatch, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitLabeledStatement, visitLiteral, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitTry, visitTypeParameter, visitWhileLoop, visitWildcard |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NullnessVisitor(NullnessChecker checker, CompilationUnitTree root)
NonNull
.
checker
- the checker to useroot
- the root of the input program's AST to checkMethod Detail |
---|
public Void visitMemberSelect(MemberSelectTree node, Void p)
visitMemberSelect
in interface TreeVisitor<Void,Void>
visitMemberSelect
in class TreeScanner<Void,Void>
public Void visitEnhancedForLoop(EnhancedForLoopTree node, Void p)
.iterator
call
visitEnhancedForLoop
in interface TreeVisitor<Void,Void>
visitEnhancedForLoop
in class BaseTypeVisitor<Void,Void>
public Void visitArrayAccess(ArrayAccessTree node, Void p)
visitArrayAccess
in interface TreeVisitor<Void,Void>
visitArrayAccess
in class TreeScanner<Void,Void>
public Void visitThrow(ThrowTree node, Void p)
visitThrow
in interface TreeVisitor<Void,Void>
visitThrow
in class TreeScanner<Void,Void>
public Void visitSynchronized(SynchronizedTree node, Void p)
visitSynchronized
in interface TreeVisitor<Void,Void>
visitSynchronized
in class TreeScanner<Void,Void>
public Void visitBinary(BinaryTree node, Void p)
visitBinary
in interface TreeVisitor<Void,Void>
visitBinary
in class TreeScanner<Void,Void>
public Void visitUnary(UnaryTree node, Void p)
visitUnary
in interface TreeVisitor<Void,Void>
visitUnary
in class BaseTypeVisitor<Void,Void>
public Void visitCompoundAssignment(CompoundAssignmentTree node, Void p)
visitCompoundAssignment
in interface TreeVisitor<Void,Void>
visitCompoundAssignment
in class BaseTypeVisitor<Void,Void>
public Void visitTypeCast(TypeCastTree node, Void p)
visitTypeCast
in interface TreeVisitor<Void,Void>
visitTypeCast
in class BaseTypeVisitor<Void,Void>
public Void visitMethod(MethodTree node, Void p)
BaseTypeVisitor
visitMethod
in interface TreeVisitor<Void,Void>
visitMethod
in class BaseTypeVisitor<Void,Void>
public Void visitAssignment(AssignmentTree node, Void p)
BaseTypeVisitor
BaseTypeVisitor.commonAssignmentCheck(Tree, ExpressionTree, String, Object)
.
If the subtype check fails, it issues a "assignment.invalid" error.
visitAssignment
in interface TreeVisitor<Void,Void>
visitAssignment
in class BaseTypeVisitor<Void,Void>
protected boolean checkMethodInvocability(AnnotatedTypeMirror.AnnotatedExecutableType method, MethodInvocationTree node)
checkMethodInvocability
in class BaseTypeVisitor<Void,Void>
method
- the type of the invoked methodnode
- the method invocation node
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |