Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8355204

Consider simplifying type metadata stripping

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • tools

      There are two methods for removing type metadata (in particular annotations): stripMetadataIfNeeded, and stripMetadata

      ( stripMetadataIfNeeded was added for https://bugs.openjdk.org/browse/JDK-8031744
      * The unconditional stripMetadata was added for https://bugs.openjdk.org/browse/JDK-8144580
      * stripMetadata was substantially reworked to ensure it always stripped annotations in https://bugs.openjdk.org/browse/JDK-8042981, which also updated the spec for Types' utility methods to clarify when type annotations were preserved, and also 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

      stripMetadataIfNeeded strips metadata for types from type projections, substitutions, and mappings.

      Today, it is only called in three places:

      * RichDiagnosticFormatter (which appears to be the cause of https://bugs.openjdk.org/browse/JDK-8355065)
      * Types#directSupertypes, which is specified as preserving type annotations, so this also seems incorrect
      * Trees#getTypeMirror, which doesn't specify whether or not type annotations are preserved

      I am wondering if stripMetadataIfNeeded is still need at this point, or if it's worth considering using stripMetadata when unconditional type annotation stripping is required, and removing stripMetadataIfNeeded.

            cushon Liam Miller-Cushon
            cushon Liam Miller-Cushon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: