public class NullPointer extends Object
| Constructor and Description |
|---|
NullPointer(Statement statement) |
NullPointer(Statement sourceStatement,
Val sourceVariable,
Statement statement,
Val variable,
PAutomaton<Statement,INode<Val>> openingContext,
PAutomaton<Statement,INode<Val>> closingContext) |
| Modifier and Type | Method and Description |
|---|---|
PAutomaton<Statement,INode<Val>> |
getClosingContext()
The closing context of a NullPointer provides the call stack via which a variable containing null returns to a
caller.
|
soot.SootMethod |
getMethod()
Returns the method of the statement at which the null pointer occurs.
|
PAutomaton<Statement,INode<Val>> |
getOpeningContext()
The opening context of a NullPointer provides the call stack under which the null pointer occurs.
|
Statement |
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.
|
Statement |
getStatement()
The statement at which a null pointer occurred.
|
Val |
getVariable()
The variable that contains "null" and which provokes at
the statement a
NullPointerException. |
String |
toString() |
public NullPointer(Statement statement)
public Val getVariable()
the statement a
NullPointerException.public Statement getStatement()
getVariable is nullpublic Statement getSourceStatement()
public Val getSourceVariable()
public soot.SootMethod getMethod()
public PAutomaton<Statement,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 PAutomaton<Statement,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.Copyright © 2023. All rights reserved.