Integrated: 8351431: Type annotations on new class creation expressions can't be retrieved
Liam Miller-Cushon
cushon at openjdk.org
Thu Apr 3 16:12:04 UTC 2025
On Fri, 7 Mar 2025 17:26:25 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:
> Hello,
>
> Please consider this fix for [JDK-8351431](https://bugs.openjdk.org/browse/JDK-8351431), which allows type annotations on the class type of a `new` class creation expression to be retrieved by the Compiler Tree API.
>
> Currently `Attr` is skipping `annotateTypeSecondStage` for all new class types, but the special case only needs to be applied to anonymous new class creation expressions to be consistent with logic in `Annotate`:
>
> https://github.com/openjdk/jdk/blob/7c22b814d670deda6c2bb93b1e150975c27a165f/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java#L1162-L1166
>
> This also removes a check of `isNewClass` (now `isNewAnonymousClass`) in `InvalidCanonicalConstructorInRecord`, because the field was only set before descending into a `JCNewClass.clazz`, which can't contain return statements.
This pull request has now been integrated.
Changeset: 6b7b3247
Author: Liam Miller-Cushon <cushon at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/6b7b3247b1b247ca38ba51a2c2de924eea9b2aba
Stats: 160 lines in 3 files changed: 153 ins; 1 del; 6 mod
8351431: Type annotations on new class creation expressions can't be retrieved
Reviewed-by: vromero
-------------
PR: https://git.openjdk.org/jdk/pull/23946
More information about the compiler-dev
mailing list