Annotation and compact constructor
Tagir Valeev
amaembo at gmail.com
Tue Aug 25 05:49:25 UTC 2020
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