Annotation and compact constructor

Vicente Romero vicente.romero at oracle.com
Fri Sep 4 17:50:43 UTC 2020


Hi Tagir,

I have fixed the bug you reported [1] in the jdk repo [2]

Thanks,
Vicente

[1] https://bugs.openjdk.java.net/browse/JDK-8252307
[2] http://hg.openjdk.java.net/jdk/jdk/rev/e5d81a790eae

On 8/25/20 1:49 AM, Tagir Valeev wrote:
> Hello!
>
> The following code cannot be compiled by javac (tried build 15-ea+33-1546):
>
> import java.lang.annotation.*;
>
> @Target({ElementType.FIELD, ElementType.CONSTRUCTOR})
> @Retention(RetentionPolicy.RUNTIME)
> @interface Ann {
> }
> record R(@Ann String str) {
>    R {}
> }
>
> Error message:
> R.java:7: error: annotation type not applicable to this kind of declaration
> record R(@Ann String str) {
>           ^
> 1 error
> 1 warning
>
> I would expect that the annotation is silently propagated to the
> compact constructor declaration. Is this correct behavior?
>
> With best regards,
> Tagir Valeev.



More information about the amber-dev mailing list