typetools / typetools/checker-framework
Constructor should not assume static fields are initialized
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Before the constructor is invoked, static initializers and static blocks are executed. This suggests that the Initialization Checker can assume that static fields are initialized in the constructor.
However, if any user-defined code -- including callbacks such as executions of equals() and hashCode() -- appears in a static initializer or static block, then static fields cannot be assumed to be initialized within the constructor.
A minimal test case appears in checker-framework/checker/tests/initialization/fbc/Issue556a.java , and a longer test case with explanations appears in checker-framework/checker/tests/initialization/fbc/Issue556b.java .
Thanks to Ed Price for pointing out the issue and supplying an initial test case.
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 checker/tests/initialization/fbc/Issue556a.java and Issue556b.java, then run the relevant Initialization Checker tests to reproduce the reported behavior. Trace how constructor assumptions are handled when static initializers or blocks execute user-defined callbacks. Done means both cases are correctly checked without regressing existing initialization tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100