Integrated: 8207017: Type annotations on anonymous classes in initializer blocks not written to class file
Vicente Romero
vromero at openjdk.org
Tue Feb 14 14:31:03 UTC 2023
On Fri, 10 Feb 2023 22:43:41 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> Javac is not writing type annotations applied to anonymous classes inside of instance or static initializers. Basically for code like:
>
>
> import java.lang.annotation.*;
>
> class X {
>
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.TYPE_USE)
> public @interface TA {
> String value() default "empty";
> }
>
> {
> class Local {}
> new @TA("LocalInstanceInitializerAnnonymous") Local() {};
> }
>
> static {
> class Local {}
> new @TA("LocalStaticAnnonymous") Local() {};
> }
> }
>
> not type annotations are generated as attributes of methods <init> or <clinit>. This PR is fixing this issue. The annotations are currently generated if the anonymous class is declared inside an instance or static method. The issue is only with initializers,
>
> TIA
This pull request has now been integrated.
Changeset: 2ef001e0
Author: Vicente Romero <vromero at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/2ef001e09774fd0cce7a6bd917dd46033cf4c4d9
Stats: 29 lines in 2 files changed: 26 ins; 1 del; 2 mod
8207017: Type annotations on anonymous classes in initializer blocks not written to class file
Reviewed-by: jlahoda
-------------
PR: https://git.openjdk.org/jdk/pull/12519
More information about the compiler-dev
mailing list