|
1 | 1 | # null-pointer-analysis-examples
|
2 | 2 |
|
3 | 3 | Demonstrates capabilities of some java tools to analyze (potential) null references. These tools are:
|
4 |
| -- [eclipse (4.6)](https://www.eclipse.org) |
5 |
| -- [IntelliJ (2017.1)](https://www.jetbrains.com/idea/) |
| 4 | +- [eclipse (4.7)](https://www.eclipse.org) |
| 5 | +- [IntelliJ (2017.2)](https://www.jetbrains.com/idea/) |
6 | 6 | - [The Checker Framework](https://checkerframework.org/)
|
7 | 7 |
|
8 | 8 | Open the various java sources and read the comments to have an understanding of various checks that can be done (or not)
|
9 | 9 | by these tools.
|
10 | 10 |
|
11 | 11 | :warning: It is NORMAL that your IDE shows errors in the source files if it supports some checks for null reference analysis.:warning:
|
12 |
| - |
13 | 12 | The default javac compiler does not report any error however.
|
14 | 13 |
|
| 14 | +## Comparison |
| 15 | + |
| 16 | +Feature | Eclipse IDE 4.7.1 or jdt | Checker Framework | IntelliJ 2017.2.5 |
| 17 | +------- | ------------------ | ----------------- | -------- |
| 18 | +IDE support | :white_check_mark: | :white_check_mark: using plugin | :white_check_mark: |
| 19 | +Command line support | :white_check_mark: | :white_check_mark: | To be tested |
| 20 | +Java 8 type annotations support | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| 21 | +Multiple annotations classes supported | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| 22 | +External annotations support | :white_check_mark: using .eea files | :white_check_mark: using stubs files | :white_check_mark: using xml files |
| 23 | +External annotations provided for common libraries | :red_circle: community effort with [lastnpe.org](http://lastnpe.org)| :white_check_mark: JDK, Guava | :white_check_mark: JDK |
| 24 | +IDE support to create external annotations | :white_check_mark: | :warning: using command line tools | :white_check_mark: |
| 25 | +Treat all types as @Nonnull by default, unless annotated wih @Nullable | :white_check_mark: using @NonNullByDefault for each package, allows to define the scope: field, parameters, return, generic types, etc... | :white_check_mark: by default, customizable with @DefaultQualifier | :white_check_mark: |
| 26 | +@Polynull support | :red_circle: | :white_check_mark: using [@PolyNull](https://checkerframework.org/manual/#qualifier-polymorphism) | :white_check_mark: using [@Contract](https://www.jetbrains.com/help/idea/2017.1/contract-annotations.html), for instance @Contract("!null->!null;null->null") |
| 27 | +Method contract support (e.g. handle ``if(StringUtils.hasText(str)) {str...}`` | :red_circle: | :question: | :white_check_mark: using @Contract |
| 28 | +Automatic inference of nullability constraints in external libraries | :red_circle: | :red_circle: | :white_check_mark: for @NonNull and some @Contract. [Disabled for @Nullable due to too many false positives](https://youtrack.jetbrains.com/issue/IDEA-130063) |
| 29 | +Treat main, test or generated sources differently | :warning: not in IDE, unless ignoring all non-fatal errors for a source folder| :white_check_mark: | :white_check_mark: |
| 30 | + |
15 | 31 | ## Eclipse
|
16 |
| -Last version tested: eclipse 4.6.3. |
| 32 | +Last version tested: eclipse 4.7.1 |
17 | 33 |
|
18 | 34 | The best analysis is performed using [external annotations](http://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.user/tasks/task-using_external_null_annotations.htm?cp=1_3_9_2).
|
19 | 35 |
|
@@ -212,19 +228,3 @@ $ mvn clean test -P checker-framework
|
212 | 228 | /Users/slaurent/Developer/repos/null-pointer-analysis-examples/src/main/java/test/EverythingNonNullByDefault.java:[25,11] error: [initialization.fields.uninitialized] the constructor does not initialize fields: address
|
213 | 229 | ...
|
214 | 230 | ```
|
215 |
| -## Comparison |
216 |
| - |
217 |
| -Feature | Eclipse IDE or jdt | Checker Framework | IntelliJ |
218 |
| -------- | ------------------ | ----------------- | -------- |
219 |
| -IDE support | :white_check_mark: | :white_check_mark: using plugin | :white_check_mark: |
220 |
| -Command line support | :white_check_mark: | :white_check_mark: | :red_circle: |
221 |
| -Java 8 type annotations support | :white_check_mark: | :white_check_mark: | :red_circle: ``List<@Nonnull String>`` is the same as ``List<String>``, no error for ``list.add(null)``. |
222 |
| -Multiple annotations classes supported | :white_check_mark: | :white_check_mark: | :white_check_mark: |
223 |
| -External annotations support | :white_check_mark: using .eea files | :white_check_mark: using stubs files | :white_check_mark: using xml files |
224 |
| -External annotations provided for common libraries | :red_circle: community effort with [lastnpe.org](http://lastnpe.org)| :white_check_mark: JDK, Guava | :white_check_mark: JDK |
225 |
| -IDE support to create external annotations | :white_check_mark: | :warning: using command line tools | :white_check_mark: |
226 |
| -Treat all types as @Nonnull by default, unless annotated wih @Nullable | :white_check_mark: using @NonNullByDefault for each package, allows to define the scope: field, parameters, return, generic types, etc... | :white_check_mark: by default, customizable with @DefaultQualifier | :white_check_mark: IDE setting :question: global? |
227 |
| -@Polynull support | :red_circle: | :white_check_mark: using [@PolyNull](https://checkerframework.org/manual/#qualifier-polymorphism) | :white_check_mark: using [@Contract](https://www.jetbrains.com/help/idea/2017.1/contract-annotations.html), for instance @Contract("!null->!null;null->null") |
228 |
| -Method contract support (e.g. handle ``if(StringUtils.hasText(str)) {str...}`` | :red_circle: | :question: | :white_check_mark: using @Contract |
229 |
| -Automatic inference of nullability constraints in external libraries | :red_circle: | :red_circle: | :white_check_mark: for @NonNull and some @Contract. [Disabled for @Nullable due to too many false positives](https://youtrack.jetbrains.com/issue/IDEA-130063) |
230 |
| -Treat main, test or generated sources differently | :warning: not in IDE, unless ignoring all non-fatal errors for a source folder| :white_check_mark: | :white_check_mark: |
0 commit comments