Skip to content

Nullness Checker unsoundness with inner classes #7239

@msridhar

Description

@msridhar
import org.checkerframework.checker.nullness.qual.Nullable;
public class Test {
    class A<X> {
        X field;
        A(X val) {this.field = val;}
        class B<Y> {
            X get() { return A.this.field; }
        }
    }
    void test(A<@Nullable String>.B<@Nullable String> b) {
        b.get().hashCode();
    }
    public static void main(String[] args) {
      Test t = new Test();
      t.test(t.new A<@Nullable String>(null).new B<@Nullable String>());
    }
}

This passes the Nullness Checker but throws an NPE at runtime. I think there should be an error reported inside test() at the de-reference of b.get().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions