[lworld] RFR: 8280456: [lworld] javac should allow compilation with abstract java.lang.Object class

Srikanth Adayapalam sadayapalam at openjdk.java.net
Tue Jan 25 10:20:37 UTC 2022


On Tue, 25 Jan 2022 10:11:09 GMT, Srikanth Adayapalam <sadayapalam at openjdk.org> wrote:

> - Warn on attempt to instantiate Object
>     - If j.l.O is seen as abstract, don't complain about abstract class instantiation
>     - Reroute instantiation to calls of java.util.Objects.newIdentity
>     - Extend treatment to both constructor invocations and constructor references.

Notes for reviewer:

This is a follow up to JDK-8237073 - that fix by oversight did not include treatment of constructor references of the form (Object::new) - these need to be warned about and these also need to rerouted to java.util.Objects.newIdentity(). The present
fix does that.

The present fix in addition ensures that javac does not emit an error of the form:


ObjectTest.java:5: error: Object is abstract; cannot be instantiated
    Object o = new Object();


when the JDK changes to make Object abstract. 

Javac should not choke on existing code attempting instantiate object.

-------------

PR: https://git.openjdk.java.net/valhalla/pull/616



More information about the valhalla-dev mailing list