JDK-8303820 : Simplify type metadata
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-03-08
  • Updated: 2023-03-17
  • Resolved: 2023-03-10
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.
JDK 21
21 b14Fixed
Related Reports
Relates :  
Description
The TypeMetadata class can be used to attach additional information to javac types. There is support for comparing types with metadata (namely, equalsNoMetadata) which is correctly used in all type routines (e.g. subtyping) - making this an excellent candidate to handle all side-data in a centralized fashion.

Unfortunately, the type metadata API is not very friendly to use - it acts as a map, and you can only add to it by "combining" new metadata in. This parts feels slightly over-designed.

A simpler approach is possible where TypeMetadata is just a marker interface for metadata-like stuff (e.g. records). Then a type just keeps track of the list of metadata objects attached to it.
Comments
Changeset: b9951dd6 Author: Maurizio Cimadamore <mcimadamore@openjdk.org> Date: 2023-03-10 13:12:50 +0000 URL: https://git.openjdk.org/jdk/commit/b9951dd63997b6330001311c925e171f4645a28b
10-03-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/12924 Date: 2023-03-08 13:57:51 +0000
08-03-2023