0

first I use annotation to receive some params, String and String[], e.g.

@Retention(RetentionPolicy.RUNTIME)  
@Target(ElementType.METHOD)  
@Documented  
public @interface RedisCacheAble {  
    String value() default "";   
    String[] names() default {};  
} 

@RedisCacheAble(value="XXOO",names = {"a","b"} )
public OrderDetailPO orderTestAble(String op) {}

then my manager said that the value and names must use const because other place may use this values, so I change my code like that:

public static final String XXOO = "xxoo";
    public static final String XOARR = {"orderCode","accountId"};
    @RedisCacheAble(value=XXOO, names = XOARR )
    public OrderDetailPO orderTestAble(String op) {  //

    }

unfortunately the eclipse throw a error: XOARR must initial as an Array, so it's seems annotation can not recognized a const array, any one know why?

vvsueprman
  • 143
  • 1
  • 2
  • 10

1 Answers1

0

Because annotation attribute value must be const. But even your array is final, its conent is also changeable. So it's not annotation can't recognize const array, there is no const array.

Dean Xu
  • 4,438
  • 1
  • 17
  • 44