[External] : Re: Making Object abstract

Brian Goetz brian.goetz at oracle.com
Sat May 8 01:34:40 UTC 2021

 From a compatibility perspective, we can't outlaw either `new Object()` 
or `new j/l/Object`, but we can (a) add Object::newInstance and (b) warn 
on recompilation to switch to `Object::newInstance`.

On 5/7/2021 9:06 PM, Dan Heidinga wrote:
>> 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-observers mailing list