biddyweb / checker-framework

Automatically exported from code.google.com/p/checker-framework
Other
0 stars 1 forks source link

Nullness checker: "found" / "required" details are not shown for some cases (only with maven) #397

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version of the tested checker framework is 1.8.10
Details about system:
Apache Maven 3.2.1
Java version: 1.8.0_05, vendor: Oracle Corporation
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "dos"

Tried to create simple maven project to test nullness checker and found 
interesting behavior: depending on the code (to be more precise - on the 
ordering of the same code) maven either shows or doesn't show details about 
failed cases. Both projects are attached as zip archives.

When executing "mvn compile" on the project "checker_ok.zip" - getting 
following output(as expected):
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on 
project checker: Compilation failure: Compilation failure:
[ERROR] D:\src\checker\src\main\java\checker\App.java:[7,14] error: 
[argument.type.incompatible] incompatible types in argument.
[ERROR] found   : @FBCBottom @Nullable null
[ERROR] 
[ERROR] required: @Initialized @NonNull String
[ERROR] D:\src\checker\src\main\java\checker\App.java:[9,27] error: 
[dereference.of.nullable] dereference of possibly-null reference nullableString
[ERROR] -> [Help 1]

Moving call of one method a bit upper (please check project "checker_nok.zip") 
and build output doesn't have details about "required" and "found" types:
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on 
project checker: Compilation failure: Compilation failure:
[ERROR] D:\src\checker\src\main\java\checker\App.java:[8,27] error: 
[dereference.of.nullable] dereference of possibly-null reference nullableString
[ERROR] D:\src\checker\src\main\java\checker\App.java:[9,14] error: 
[argument.type.incompatible] incompatible types in argument.
[ERROR] -> [Help 1]

If you aren't able to see attached projects for some reason - here are code 
snippets for "checker_ok.zip":
package checker;

import org.checkerframework.checker.nullness.qual.Nullable;

public class App {
    public static void main(String[] args) {
        print(null);
        final String nullableString = get();
        System.out.println(nullableString.toUpperCase());
    }

    @Nullable
    private static String get() {
        return null;
    }

    private static void print(final String nonNull) {

    }
}

and for "Checker_nok.zip":
package checker;

import org.checkerframework.checker.nullness.qual.Nullable;

public class App {
    public static void main(String[] args) {
        final String nullableString = get();
        System.out.println(nullableString.toUpperCase());
        print(null);
    }

    @Nullable
    private static String get() {
        return null;
    }

    private static void print(final String nonNull) {

    }
}

Both projects produce proper output when compiling using command line 
(D:\src\checker\src\main\java\checker>java -jar 
D:\downloads\checker-framework\checker-framework-1.8.10\checker\dist\checker.jar
  -processor org.checkerframework.checker.nullness.NullnessChecker App.java)

Original issue reported on code.google.com by anatoliy...@gmail.com on 10 Feb 2015 at 1:35

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by michael.ernst@gmail.com on 10 Feb 2015 at 10:10