lovubuntu / checker-framework

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

A couple more -AconcurrentSemantic / MonotonicNonNull issues #350

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
class Test1 {

    @MonotonicNonNull
    private volatile String x;

    void setX(String x) {
        this.x = x;
    }

    void test() {
        if (x == null) {
            x = "";
        }
        x.toString();
    }
}

==>  error: [dereference.of.nullable] dereference of possibly-null reference x
        x.toString();
        ^

class Test2 {

    @MonotonicNonNull
    private volatile String x;

    void setX(String x) {
        this.x = x;
    }

    void test() {
        if (x == null) {
            x = "";
        }
        setX(x);
    }
}

==> error: [argument.type.incompatible] incompatible types in argument.
        setX(x);
             ^

class Test3 {

    @MonotonicNonNull
    private volatile String x;

    @EnsuresNonNull("x")
    void setX(String x) {
        this.x = x;
    }
}

==> error: [contracts.postcondition.not.satisfied] the postcondition about 
'this.x' of this method is not satisfied
    void setX(String x) {
         ^

Original issue reported on code.google.com by trask.st...@gmail.com on 30 Aug 2014 at 8:35

GoogleCodeExporter commented 9 years ago
Hi Trask,

I have reproduced this. A fix will probably go out with the Feb 1 release.

Thanks!

Original comment by mcart...@cs.washington.edu on 23 Jan 2015 at 6:28

GoogleCodeExporter commented 9 years ago

Original comment by mcart...@cs.washington.edu on 26 Jan 2015 at 10:58

GoogleCodeExporter commented 9 years ago
The root cause was that the dataflow analysis was ignoring updates to 
@Monotonic fields when concurrentSemantics was enabled. Pushed fix to repo.

Original comment by mcart...@cs.washington.edu on 26 Jan 2015 at 11:00

GoogleCodeExporter commented 9 years ago
Fixed in release 1.8.10 of the Checker Framework.

Original comment by mcart...@cs.washington.edu on 30 Jan 2015 at 10:57