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

Liam Miller-Cushon cushon at openjdk.org
Mon Aug 12 17:18:38 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.

This pull request has now been integrated.

Changeset: 8d083147
Author:    Liam Miller-Cushon <cushon at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/8d0831478338e9b084b2c47f46eba9faae3a5eb6
Stats:     109 lines in 2 files changed: 25 ins; 44 del; 40 mod

8337795: Type annotation attached to incorrect type during class reading

Reviewed-by: vromero

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

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


More information about the compiler-dev mailing list