RFR: 8374020: Inconsistent handling of type updates in typeWithAnnotations

Jan Lahoda jlahoda at openjdk.org
Tue Feb 24 14:18:18 UTC 2026


Consider code like (after https://github.com/openjdk/jdk/pull/29817):

@TA List<String> l1;
@TA String[] l2;


Using the Trees API to get the type of the `l1` and `l2` declarations, the resulting types include `@TA` at appropriate places. So that the type got from `@TA List<String>` (i.e. the `l1`'s type). But the type for `@TA String[]` (i.e. the `l2`'s type) does not include `@TA`. That seems inconsistent, we should presumably set the augmented types to array types as well.

The same happens for type vars and union types as well.

This PR collects the annotation-augmented types, and sets them into the AST node that represents the type on one place.

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

Depends on: https://git.openjdk.org/jdk/pull/29817

Commit messages:
 - 8374020: Inconsistent handling of type updates in typeWithAnnotations

Changes: https://git.openjdk.org/jdk/pull/29892/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29892&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8374020
  Stats: 155 lines in 2 files changed: 147 ins; 3 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/29892.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29892/head:pull/29892

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


More information about the compiler-dev mailing list