Community
Participate
Working Groups
*--- In other words, it is permissible to omit the curly braces when a single-element array is to be associated with an array-valued annotation type element. *--- Above is from JLS3.0 But I found if JDT apt env, when an annotation has an array type element, and used with a single-element array but without the optional curly barces, call to get the element value will return a non-array value, and finally caused a runtime ClassCastException. That's to say, if we have one annotation defined like this: public @DemoAnno { String[] value(); } And used it like: @DemoAnno("whatever") And we try the following when processing it: DemoAnno da = Declaration.getAnnotation(DemoAnno.class); String[] dav = da.value(); // here it returns the String rather than the String array. And this will finally cause an unchecked ClassCastException.
This bug has been resolved. Duplicate of 103241. https://bugs.eclipse.org/bugs/show_bug.cgi?id=103241 *** This bug has been marked as a duplicate of 10 ***