Withdrawn: 8355204: Consider simplifying type metadata stripping

duke duke at openjdk.org
Mon Jul 28 19:12:02 UTC 2025


On Mon, 21 Apr 2025 16:41:15 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

> 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.

This pull request has been closed without being integrated.

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

PR: https://git.openjdk.org/jdk/pull/24775


More information about the compiler-dev mailing list