Type annotation on record component doesn't seem to be supported by javac ?
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed Oct 9 08:16:42 UTC 2019
It's a test with sealed + record.
package jdk14;
public sealed interface AllStructures {
final class ClassSubType implements AllStructures { }
record RecordSubType(@Ann int component1, @TypeAnn String component2) implements AllStructures { }
}
with:
package jdk14;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.RECORD_COMPONENT)
@Retention(RetentionPolicy.CLASS)
public @interface Ann {
}
and:
package jdk14;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TypeAnn {
}
and i'm using the branch "records-and-sealed", so it can be a bad merge ?
cheers,
Rémi
----- Mail original -----
> De: "Vicente Romero" <vicente.romero at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>, "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Mercredi 9 Octobre 2019 06:07:47
> Objet: Re: Type annotation on record component doesn't seem to be supported by javac ?
> Hi Remi,
>
> Getting that error messages looks weird, what's the full test case?
>
> Thanks,
> Vicente
>
> On 10/8/19 6:26 PM, Remi Forax wrote:
>> 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