Annotation and compact constructor

Tagir Valeev amaembo at
Tue Aug 25 05:49:25 UTC 2020


The following code cannot be compiled by javac (tried build 15-ea+33-1546):

import java.lang.annotation.*;

@Target({ElementType.FIELD, ElementType.CONSTRUCTOR})
@interface Ann {
record R(@Ann String str) {
  R {}

Error message: 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