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

Vicente Romero vromero at openjdk.org
Fri Aug 9 19:40:31 UTC 2024


On Sun, 4 Aug 2024 19:49:20 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.

looks sensible

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

Marked as reviewed by vromero (Reviewer).

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


More information about the compiler-dev mailing list