Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@MonotonicNonNull and @Nullable fields now prevent final-class constructors from calling a supermethod from within an anonymous class or lambda #641

Closed
cpovirk opened this issue Nov 27, 2023 · 0 comments · Fixed by #642
Assignees

Comments

@cpovirk
Copy link

cpovirk commented Nov 27, 2023

$ cat I3.java
import org.checkerframework.checker.nullness.qual.Nullable;

final class I2 extends Z {
  @Nullable String s;

  I2() {
    use(() -> init());
    use(
        new Runnable() {
          @Override
          public void run() {
            init();
          }
        });
  }

  void init() {}
}

class Z {
  void use(Runnable r) {}
}

$ checker/bin/javac -processor nullness I3.java
I3.java:7: error: [method.invocation.invalid] call to use(java.lang.Runnable) not allowed on the given receiver.
    use(() -> init());
       ^
  found   : @UnderInitialization(Z.class) Z
  required: @Initialized Z
I3.java:8: error: [method.invocation.invalid] call to use(java.lang.Runnable) not allowed on the given receiver.
    use(
       ^
  found   : @UnderInitialization(Z.class) Z
  required: @Initialized Z
2 errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants