typetools / typetools/checker-framework
Anonymous classes and onlyDefs
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
This small example produces an error from the Nullness Checker:
import org.checkerframework.checker.nullness.qual.Nullable;
class Test {
@Nullable Object f;
Runnable r = new Runnable() {
public void run() {
f.toString();
}
};
}
However, there is no way to use -AonlyDefs to check this class including all contained anonymous classes.
-AonlyDefs=Test should check a class plus all contained anonymous classes (and lambdas).
The current check for the class name in onlyDefs should be extended to also check the enclosing top-level class.
This check is in https://github.com/typetools/checker-framework/blob/master/framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java method boolean shouldSkipDefs(ClassTree node)
This was raised in https://github.com/typetools/checker-framework/issues/904#issuecomment-445409730 . It is very useful to be able to select the scope of type checking, but then very surprising if anonymous classes aren't checked.
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 in framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java at shouldSkipDefs(ClassTree node), and review how -AonlyDefs currently matches class names. Run the provided Nullness Checker example with -AonlyDefs=Test; done means Test and its contained anonymous classes and lambdas are checked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100