java 中没有任何参数的注释是什么意思?

What does mean annotation without any params in java?

我试图从 JDK 中理解 @Functional 接口,但无法理解为什么他们创建了这个没有正文的注释?

我不明白在class描述中使用@FunctionalInterface 和不使用有什么区别?这个没有参数的注释提供了什么?

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface FunctionalInterface {}

如果你添加它,有人将无法在不破坏你的情况下添加更多方法 functional interface 并且会出现编译时错误:

Invalid '@FunctionalInterface' annotation; MyInterface is not a functional interface

If a type is annotated with this annotation type, compilers are required to generate an error message unless:

  • The type is an interface type and not an annotation type, enum, or class.
  • The annotated type satisfies the requirements of a functional interface.