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

前端 未结 7 2013
渐次进展
渐次进展 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:08

    It seem there is one other way of doing it.

    I don't like this either, but it might work.

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

    So basically you create an empty Array instead. This seems to allow a default value.

提交回复
热议问题