eisop / checker-framework

Pluggable type-checking for Java
https://eisop.github.io/
Other
15 stars 16 forks source link

[Purity checker] Purity checker does not run as expected #760

Open Ao-senXiong opened 2 months ago

Ao-senXiong commented 2 months ago

commands:

 java -jar checker/dist/checker.jar -processor org.checkerframework.framework.util.PurityChecker Demo.java

Input:

import org.checkerframework.dataflow.qual.Pure;
public class Demo {
    Object field;;
    @Pure
    public void impureMethod() {
        field = new Object();
    }
    @Pure
    public Object pureMethod() {
        return field;
    }
}

Outputs: Pass without issue error

Expectation: Error on impuremethod.

Apply -AcheckPurityAnnotations will successfully issue the error. However, run PurityChecker directly should not need the flag. Think about how to enable it by default and add some test suite.