Java 注解中字段和方法的默认修饰符是什么?

Which are the default modifiers for fields and methods in a Java annotation?

xm 的默认修饰符是什么
public @interface Anno {
    int m() default x;
    int x = 10;
}

?

我假设上面的代码等同于:

public @interface Anno {
    public int m() default x;
    public static final int x = 10;
}

修饰符 publicpublic static final 是多余的,但我没有找到官方解释。

我在看这里: https://docs.oracle.com/javase/8/docs/technotes/guides/language/annotations.html https://docs.oracle.com/javase/tutorial/java/annotations/index.html http://www.vogella.com/tutorials/JavaAnnotations/article.html

是否有关于这些修饰符的文档?或者有人可以提供 "formal" 解释吗?

是的,我相信你是对的 - 我发现支持这一点的一点文档在 JLS 9.6:

Unless explicitly modified herein, all of the rules that apply to normal interface declarations apply to annotation type declarations.

所以它基本上表现得像一个普通接口,其中 publicabstract 是冗余的,所有字段都是隐式静态和最终的。