typetools / typetools/checker-framework

Interaction between NotOnlyInitialized and UnderInitialization

Open
#7,373 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

There appears to be an odd interaction between NotOnlyInitialized and UnderInitialization.
Reading https://checkerframework.org/manual/#fig-initialization-hierarchy and the sections after it, I understand that an object is considered UnderInitialization for itself when all of the non-null fields have been assigned.
I have a class that has a NotOnlyInitialized field and a NonNull field. Once both fields are initialized I call a private method on the class. At this point I expect the state of this to be UnderInitialization(current class), however it's UnderInitialization(parent class).

Steps to reproduce:

  1. git clone https://github.com/jpschewe/checker-bugs.git
  2. cd checker-bugs
  3. git checkout notonlyinitialized-underinitialization
  4. ./gradlew clean; ./gradlew classes

Resulting error

/home/jpschewe/projects/checker-bugs/src/main/java/net/mtu/eggplant/checker/issue4613/SchedulerUI.java:25: error: [method.invocation] call to createMenubar() not allowed on the given receiver.
    createMenubar();
                 ^
  found   : @UnderInitialization(javax.swing.JFrame.class) @NonNull SchedulerUI
  required: @UnderInitialization(net.mtu.eggplant.checker.issue4613.SchedulerUI.class) @NonNull SchedulerUI
1 error

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Clone jpschewe/checker-bugs, check out notonlyinitialized-underinitialization, and run ./gradlew clean; ./gradlew classes to reproduce the error. Start with src/main/java/net/mtu/eggplant/checker/issue4613/SchedulerUI.java and the Checker Framework initialization hierarchy documentation; done means the reported method.invocation error is resolved while the example still builds.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.