eisop / checker-framework

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

Further clean up qualifierdefaults #755

Open Ao-senXiong opened 2 months ago

Ao-senXiong commented 2 months ago

Resource leak checker is failing during the clean up in this PR https://github.com/eisop/checker-framework/pull/746 We used a ugly hacky way to make resource leak checker happy, see https://github.com/eisop/checker-framework/pull/746/commits/56afa4e542f4a0ed7710ec0c208139a4add072ab

Here is the minimal test case for it.

public class Test<S> {
    public S foo() {
        S s = joo(new A());
        return null;
    }

    public S joo(A b) {
        return null;
    }
}

class A{}
java -jar checker/dist/checker.jar -processor resourceleak Test.java
Test.java:3: error: [required.method.not.known] The checker cannot determine the must call methods of s or any of its aliases, so it could not determine if they were called. Typically, this error indicates that you need to write an @MustCall annotation (often on an unconstrained generic type).
        S s = joo(new A());
          ^
  The type of object is: S.
  Reason for going out of scope: regular method exit
1 error

Think about how to clean it up and why resource leak checker is failing by the change.