RFR: 8207017: Type annotations on anonymous classes in initializer blocks not written to class file
Vicente Romero
vromero at openjdk.org
Fri Feb 10 22:50:20 UTC 2023
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
-------------
Commit messages:
- 8207017: Type annotations on anonymous classes in initializer blocks not written to class file
Changes: https://git.openjdk.org/jdk/pull/12519/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12519&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8207017
Stats: 29 lines in 2 files changed: 26 ins; 1 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/12519.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12519/head:pull/12519
PR: https://git.openjdk.org/jdk/pull/12519
More information about the compiler-dev
mailing list