JDK-8237959 : [lworld] replace use of `new Object()`
  • Type: Bug
  • Component: core-libs
  • Affected Version: repo-valhalla
  • Priority: P4
  • Status: Resolved
  • Resolution: Withdrawn
  • OS: generic
  • CPU: generic
  • Submitted: 2020-01-28
  • Updated: 2022-05-19
  • Resolved: 2022-05-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
repo-valhallaResolved
Related Reports
Cloners :  
Description
From http://cr.openjdk.java.net/~briangoetz/valhalla/sov/02-object-model.html:

Object
Because of its role as the root type for all classes, inline and identity, Object shares many characteristics with interfaces. As noted already, there is an inline widening conversion from all inline types to Object.

However, because Object is a concrete class, it is unfortunately possible to instantiate Object directly through its constructor. And because interfaces are inherited, Object can implement neither InlineObject nor IdentityObject – but the result of instantiating new Object() must be an instance of an identity type (since there is no point instantiating Object for any other reason.)

Wriggling out of this trap will require some fancy moves. We can start by creating a static factory Object::newIdentity that returns IdentityObject, and then attempt to migrate existing source and binary usages of new Object() towards this using various tools (compiler warnings, JIT magic) – and ultimately “deprecating” the Object constructor for direct instantiation (by making it protected).
Comments
new Object() has been restored as a supported operation in Valhalla.
19-05-2022

It would be better to push this change in jdk repo. Maybe a simple approach to add a new internal factory method to create a simple lock object for java.base to use.
20-07-2021

There are 263 places in OpenJDK that use new Object() and so generate an informational note from javac - the attached log file captures these places. These need to be looked into and suitably handled so that the build process is clean and not cluttered by these notes.
20-07-2021

This is for the work required on the libraries side.
28-01-2020