Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

NPE.STAT

A NullPointerException is thrown in case of an attempt to dereference a null value. The dereference may be a function call, a read or write of a field, or an array access. NPE.STAT is reported for the result of a method call being dereferenced when the source code of the method is unavailable, but statistics indicate that it can return null. Statistics are gathered for the null checks applied to the values returned by methods.

Example 1

22     public void printAbsoluteParentPath() {
23         final File parent = f.getParentFile();
24         if (parent != null) {
25             String absolutePath = parent.getAbsolutePath();
26             System.out.println("absolute path " + absolutePath);
27         }
28     }
29 
30     public void printCanonicalParentPath() throws IOException {
31         final File parent = f.getParentFile();
32         if (parent != null) {
33             String canonicalPath = parent.getCanonicalPath();
34             System.out.println("canonical path: " + canonicalPath);
35         }
36     }
37 
38     public void printParentPath() throws IOException {
39         String path = f.getParentFile().getPath();
40         System.out.println("path " + path);
41     }

NPE.STAT is reported for line 39, since the value returned by 'getParentFile()' is usually checked for null before dereferencing, so there is a possibility of an NPE here.

Extension

This checker can be extended through the Klocwork knowledge base. See Tuning Java analysis for more information.