typetools / typetools/checker-framework

Annonymous class in field initializer needs to treat surrounding class as under initialization

Open
#904 10 comments 0 reactions 1 assignee View on GitHub

@wmdietl is already working on this.

Since Sep 7, 2016.

bug Dataflow False Negative (missing warning or unsoundness)
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

No error about clear NPE when calling function in annonymous class from constructor.
Discovered while discussing #903. Tested with v2.1.1.

class Foo {
  private final Object mBar;
  private final Runnable mRunnable =
        new Runnable() {
          @Override
          public void run() {
            // No problem, even though it NPEs.
            mBar.toString();
          }
        };

  public Foo() {
    mRunnable.run();
    mBar = "";
  }

  public static void main(String[] args) {
    new Foo();
  }
}

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.