RFR: 8355204: Consider simplifying type metadata stripping
Liam Miller-Cushon
cushon at openjdk.org
Tue Apr 29 15:03:03 UTC 2025
This change removes support for `stripMetadataIfNeeded`. After [JDK-8355065](https://bugs.openjdk.org/browse/JDK-8355065) there are only two uses of the method:
* `Types#directSupertypes`, which is specified as preserving type annotations. This change means that type metadata will be preserved for supertypes that appear in source, as well as substituted types for transitive supertypes.
* `Trees#getTypeMirror`, which doesn't specify whether or not type annotations are preserved.
`stripMetadataIfNeeded` was added for [JDK-8031744](https://bugs.openjdk.org/browse/JDK-8031744). The unconditional `stripMetadata` was added for [JDK-8144580](https://bugs.openjdk.org/browse/JDK-8144580). `stripMetadata` was substantially reworked to ensure it always stripped annotations in [JDK-8042981](https://bugs.openjdk.org/browse/JDK-8042981), which also updated the spec for Types' utility methods to clarify when type annotations were preserved, added a public API for removing annotations from types, and replaced some calls to `stripMetadataIfNeeded` with `stripMetadata` because the former didn't strip annotations in some cases where stripping was actually needed.
I think it's worth considering removing `stripMetadataIfNeeded`. The bookkeeping to keep track of whether or not metadata should be stripped is fragile, and the API use-case can be supported by either preserving metadata or unconditionally stripping it.
-------------
Commit messages:
- whitespace
- Merge remote-tracking branch 'origin/master' into stripMetadataIfNeeded
- 8355204: Consider simplifying type metadata stripping
Changes: https://git.openjdk.org/jdk/pull/24775/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24775&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8355204
Stats: 82 lines in 5 files changed: 0 ins; 68 del; 14 mod
Patch: https://git.openjdk.org/jdk/pull/24775.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/24775/head:pull/24775
PR: https://git.openjdk.org/jdk/pull/24775
More information about the compiler-dev
mailing list