Type annotation on record component doesn't seem to be supported by javac ?

Remi Forax forax at univ-mlv.fr
Tue Oct 8 22:26:58 UTC 2019


Answering to myself,
I use TYPE_PARAMETER instead of TYPE_USE when declaring the annotation (facepalm)

but anyway, with TYPE_USE
  @Target(ElementType.TYPE_USE)
  @Retention(RetentionPolicy.RUNTIME)
  public @interface TypeAnn { }

I get:
  /src/main/java/fr.umlv.record/jdk14/AllStructures.java:9: error: scoping construct cannot be annotated with type-use annotation: @jdk14.TypeAnn
    record RecordSubType(@Ann int component1, @TypeAnn String component2) {

I have no idea what a scoping construct is ?

Rémi

----- Mail original -----
> De: "Remi Forax" <forax at univ-mlv.fr>
> À: "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Mardi 8 Octobre 2019 23:54:00
> Objet: Type annotation on record component doesn't seem to be supported by javac ?

> Hi all,
> with a type annnotation on a record component defined like this
>  
>  @Target(ElementType.TYPE_PARAMETER)
>  @Retention(RetentionPolicy.RUNTIME)
>  public @interface TypeAnn { }
> 
> I get:
>  ./src/main/java/fr.umlv.record/jdk14/AllStructures.java:11: error: annotation
>  type not applicable to this kind of declaration
>    record RecordSubType(@Ann int component1, @TypeAnn String component2) {
> 
> Note: i'm using jdk 14-amber+0-df2722d9f9d0, i will test with the current source
> asap.
> 
> regards,
> Rémi


More information about the amber-dev mailing list