typetools / typetools/checker-framework
Unexpected `assignment.type.incompatible` when assigning `Integer` in lock checker
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
I'm working on getting the tests working on jdk11 (#2771) and currently having trouble getting one of the tests for lock to pass. A smaller reproduce of the test case follows. I'm not too sure if this is a bug of the checker or that this means the test needs to be changed.
Command used:
java -jar $checker/checker/dist/checker.jar com.sun.tools.javac.Main -processor lock lock-repro.java
where lock-repro.java is:
import java.util.concurrent.locks.ReentrantLock;
import org.checkerframework.checker.lock.qual.GuardedBy;
class Test {
final Object lock = new Object();
Integer dummyInteger(int n) {
return new Integer(n);
}
void integer() {
@GuardedBy("lock") Integer a;
a = new Integer(5); // works, no error
//error: [assignment.type.incompatible] incompatible types in assignment.
//a = Integer.valueOf(5);
// ^
//found : @GuardedBy({}) Integer
//required: @GuardedBy("this.lock") Integer
a = Integer.valueOf(5);
// same error as above
a = dummyInteger(5);
}
}
TODO: Update checker/tests/lock/ChapterExamples.java
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided lock-repro.java example and run the checker command against it, then inspect checker/tests/lock/ChapterExamples.java. Determine whether the incompatible assignment is checker behavior or an outdated test expectation, and update the test or issue behavior so the lock tests pass on JDK 11.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100