小编pea*_*itt的帖子

java记录上的构造函数注释

有没有办法获得像ConstructorProperties这样的注释,它@Target(CONSTRUCTOR)必须注释 java 16 记录的生成构造函数?例如:

@ConstructorProperties({"id", "filename"})
public record Person(long id, String filename) {}
Run Code Online (Sandbox Code Playgroud)

此 ^ 导致以下错误:

java: annotation type not applicable to this kind of declaration
Run Code Online (Sandbox Code Playgroud)

java constructor annotations java-record java-16

6
推荐指数
1
解决办法
148
查看次数

标签 统计

annotations ×1

constructor ×1

java ×1

java-16 ×1

java-record ×1