Making Object abstract

Dan Heidinga heidinga at redhat.com
Sat May 8 01:06:02 UTC 2021


> I would strongly discourage new developers from saying "new Object()", and I think javac/IDEs should warn about it. It's allowed purely for compatibility. If developers insist on using it, then whether we've decreed that Object is abstract or not, they're going to need to learn that "new Object()" is a special case that doesn't behave the way they expect "new Foo()" to behave.
>

I had assumed that we were making `new Object()` illegal syntax when
the Primitive Classes jep landed.  We need to keep the bytecode
sequence working for legacy classfiles but don't need the language to
support writing it in the future.  Was that incorrect?

There was also a proposal to add a Object::newObject() helper method
as a replacement for using `new Object()` which may be why I assumed
the old syntax would be illegal in the future.

--Dan



More information about the valhalla-spec-experts mailing list