RFR: 8337795: Type annotation attached to incorrect type during class reading [v2]

Vicente Romero vromero at openjdk.org
Mon Aug 12 15:07:35 UTC 2024


On Sat, 10 Aug 2024 19:17:08 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

>> This change fixes a bug in the logic for adding type annotations to types during class reading.
>> 
>> The implementation searched for contained types that type annotations applied to, and then separately rewrote the type to add the annotations using `StructuralTypeMapping`, relying on the object identity of `Type` instances to keep track of them between the two passes. This produced incorrect results if the same type (with the same identity) appeared multiple times as a contained type.
>> 
>> This fix merges the two passes into a single visitor that both locates annotated contained types, and rewrites them to add the annotations. This requires duplicating similar logic to `StructuralTypeMapping`, which seems unavoidable.
>
> Liam Miller-Cushon has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
> 
>  - Merge branch 'master' into JDK-8337795
>  - 8337795: Type annotation attached to incorrect type during class reading

Marked as reviewed by vromero (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/20460#pullrequestreview-2233323802


More information about the compiler-dev mailing list