typetools / typetools/checker-framework
PolyInitialized annotation is needed to full express initialization semantics
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
See discussion at https://github.com/typetools/jdk/pull/99#issuecomment-812756239
In brief, there are some Java standard library methods that need an PolyInitialized annotation in order to full express their semantics. The easiest example is Throwable.initCause() which is commonly invoked either from within a constructor (UnderInitialization) or immediately after construction (Initialized), and returns a self reference to support method chaining. The return value of this method is currently annotated @UnknownInitialization, which means method chaining in the style of "return new Throwable(e.getMessage()).initCause(e)" is not allowed by the initialization checker, which complains that the resulting value is @UnknownInitialization.
The method chaining pattern is also commonly used by Builder style objects (ie, new Builder().setXXX().setYYY()), and thus a PolyInitialized annotation is likely to be useful for Builder objects as well, by allowing setXXX() style methods to be invoked from within constructors (useful for more complex builder objects).
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 linked discussion and inspect the initialization checker handling for Throwable.initCause(). Determine how PolyInitialized should express calls from both UnderInitialization and Initialized contexts, including chained construction; done means the stated chaining pattern is accepted without losing the appropriate initialization state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100