[lworld] What is the default of a Primitive.ref variable?

Jesper Steen Møller jesper at selskabet.org
Fri Jul 23 10:47:24 UTC 2021

Hi list

While making a test case for bug 8210906 (making SomeClass.default a poly-expression if SomeClass is parameterized), I came across the use of .default on a reference, as in

primitive class Prim {
    int i = 42;

    public static void main(String [] args) {
        Prim.ref p = Prim.ref.default; // Does this make sense at all?
        System.out.println(p.i); // Should this NPE or print 0?

Prim.ref is the reference projection of Prim, and is nullable, and is reference type. The default of a reference is null.
But what is Prim.ref.default? Is it even a thing? Should it be disallowed?


More information about the valhalla-dev mailing list