Description
IntraJ’s Null Pointer Exception analysis can help you detect potential NullPointerException errors in your Java code. IntraJ’s analysis is intraprocedural, which means that it analyzes the code within a single method.
Example Error
Consider the following Java code:
public class Example {
public static void main(String[] args) {
String str = null;
int length = str.length();
}
}
This code assigns null
to the str
variable and then attempts to access the length()
method of the str
object. This will result in a NullPointerException
at runtime.
How IntraJ Detects Null Pointer Exceptions
IntraJ’s Null Pointer Exception analysis detects potential NullPointerException errors by analyzing the code paths that lead to a particular dereference. In the above example, IntraJ will detect that the str
variable is assigned a null
value and will identify that the subsequent call to the length()
method will result in a NullPointerException
.
–
Analyisis id: NPA