Error setting a default null value for an annotation's field

前端 未结 7 2026
渐次进展
渐次进展 2020-11-30 08:20

Why am I getting an error \"Attribute value must be constant\". Isn\'t null constant???

@Target(ElementType.TYPE)
@Retention(RetentionPolicy         


        
7条回答
  •  醉话见心
    2020-11-30 09:03

    Try this

    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    public @interface SomeInterface {
        Class bar() default void.class;
    }
    

    It does not require a new class and it is already a keyword in Java that means nothing.

提交回复
热议问题