public class NullPointerDereference extends Object implements AffectedLocation
| Modifier and Type | Field and Description |
|---|---|
static int |
RULE_INDEX |
| Constructor and Description |
|---|
NullPointerDereference(ControlFlowGraph.Edge statement) |
NullPointerDereference(Query query,
ControlFlowGraph.Edge statement,
Val variable,
wpds.impl.PAutomaton<Statement,sync.pds.solver.nodes.INode<Val>> openingContext,
wpds.impl.PAutomaton<Statement,sync.pds.solver.nodes.INode<Val>> closingContext,
List<PathElement> dataFlowPath) |
| Modifier and Type | Method and Description |
|---|---|
wpds.impl.PAutomaton<Statement,sync.pds.solver.nodes.INode<Val>> |
getClosingContext()
The closing context of a NullPointer provides the call stack via which a variable containing
null returns to a caller.
|
List<PathElement> |
getDataFlowPath() |
String |
getMessage() |
Method |
getMethod()
Returns the method of the statement at which the null pointer occurs.
|
wpds.impl.PAutomaton<Statement,sync.pds.solver.nodes.INode<Val>> |
getOpeningContext()
The opening context of a NullPointer provides the call stack under which the null pointer
occurs.
|
Query |
getQuery() |
int |
getRuleIndex() |
ControlFlowGraph.Edge |
getSourceStatement()
The source statement of the data-flow, i.e., the statement that assigns null to a variable.
|
Val |
getSourceVariable()
The source variable at the source statement.
|
ControlFlowGraph.Edge |
getStatement()
The statement at which a null pointer occurred.
|
Val |
getVariable()
The variable that contains "null" and which provokes at
the statement a
NullPointerException. |
static boolean |
isNullPointerNode(sync.pds.solver.nodes.Node<ControlFlowGraph.Edge,Val> nullPointerNode) |
String |
toString() |
public static final int RULE_INDEX
public NullPointerDereference(ControlFlowGraph.Edge statement)
public NullPointerDereference(Query query, ControlFlowGraph.Edge statement, Val variable, wpds.impl.PAutomaton<Statement,sync.pds.solver.nodes.INode<Val>> openingContext, wpds.impl.PAutomaton<Statement,sync.pds.solver.nodes.INode<Val>> closingContext, List<PathElement> dataFlowPath)
public Val getVariable()
the statement a
NullPointerException.getVariable in interface AffectedLocationpublic List<PathElement> getDataFlowPath()
getDataFlowPath in interface AffectedLocationpublic String getMessage()
getMessage in interface AffectedLocationpublic int getRuleIndex()
getRuleIndex in interface AffectedLocationpublic ControlFlowGraph.Edge getStatement()
A null pointer can occur at three different types of statements: y = x.toString(); or y = lengthof(x); or y = x.f;
getStatement in interface AffectedLocationgetVariable is nullpublic ControlFlowGraph.Edge getSourceStatement()
Examples are: x = null or x = System.getProperty(...).
public Val getSourceVariable()
public Method getMethod()
public wpds.impl.PAutomaton<Statement,sync.pds.solver.nodes.INode<Val>> getOpeningContext()
main(){
Object x = null;
foo(x); //call site context "c1"
Object y = new Object();
foo(y); //call site context "c2"
}
foo(Object z){
z.toString() //<- Variable z is null here under context c1, but *not* under c2)
}
In the example above, z is null under the calling context of call site c1.
In the case of branching, there can be multiple call site contexts leading to a null pointer. Therefore, the opening context is represented as an automaton (or graph). The edges of the automaton are labeled by the call sites, the nodes are labeled by variables or by variables at a context. For the example above, the automaton contains a transition with label foo(x)
public wpds.impl.PAutomaton<Statement,sync.pds.solver.nodes.INode<Val>> getClosingContext()
main(){
Object x;
if(...){
x = returnNull(); //b1
} else {
x = returnNotNull(); //b2
}
x.toString() //<- Variable x is null here when the program executes along branch b1
}
Object returnNull(){
Object y = null;
return y;
}
In the case above, a null pointer exception occurs when the program executes along branch b1.
There can be multiple contexts leading to a null pointer. Therefore, the closing context is represented as an automaton (or graph). The edges of the automaton are labeled by the call sites, the nodes are labeled by variables or by variables at a context. For the example above, the automaton contains a transition with label returnNull(). This indicates, that the null pointer only occurs along branch b1 but not b2.
public Query getQuery()
public static boolean isNullPointerNode(sync.pds.solver.nodes.Node<ControlFlowGraph.Edge,Val> nullPointerNode)
Copyright © 2024. All rights reserved.