Skip to content

Interactiion between NotOnlyInitialized and UnderInitialization #7373

@jpschewe

Description

@jpschewe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions