JDK-8283739 : Support compiling `.class` to a CONSTANT_Dynamic
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 19
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2022-03-27
  • Updated: 2022-03-28
Description
A DESCRIPTION OF THE PROBLEM :
Currently, all references to `<primitive>.class` get compiled to `getstatic java/lang/<Wrapper>.TYPE`, e.g.: `int.class` → `Integer.TYPE`.
I propose to compile them to a CONSTANT_Dynamic which uses `java.lang.invoke.ConstantBootstraps::primitiveClass` instead.

However, just like with JEP 280, it will be necessary to keep compiling `java.base` with the old method (and/or do a search‑and‑replace) to avoid circularities in the JDK.

## See also:
- https://bugs.openjdk.java.net/browse/JDK-8085796 (JEP 280)
- https://bugs.openjdk.java.net/browse/JDK-8187742



Comments
RFE to compile all references of `<primitive>.class` that get compiled into `getstatic java/lang/<Wrapper>.TYPE`, to a CONSTANT_Dynamic which uses `java.lang.invoke.ConstantBootstraps::primitiveClass` instead. e.g.: `int.class` → `Integer.TYPE`.
28-03-2022