(hope you don't mind my replying to this on the list)

Jeroen Frijters wrote:
One thing that's missing is the fact that annotations can have default
values:
import java.lang.annotation.*;

public @interface MyAnnotation
{
  String value() default "foo";
  Thread.State state() default Thread.State.RUNNABLE;
  Retention ret() default @Retention(RetentionPolicy.RUNTIME);
  Class clazz() default String.class;
  int[] list() default { 1, 2, 3 };
}

Interesting syntax...

Is an @interface limited to methods that return non-void types and have no arguments? Can they throw exceptions? Can an @interface extend other interfaces or @interfaces?

These default values need to be encoded too (since they appear in the
documentation). The supported types are primitive types, String, Class,
enum types, annotation types, and arrays of the preceding types.

The existing syntax for primitive constants seems like it's appropriate here...


mypackage,MyAnnotation! Pasnu annotation
mypackage,MyAnnotation!value() Painu Ljava/lang/String;:foo
mypackage,MyAnnotation!state() Painu Ljava/lang/Thread$State;:RUNNABLE
mypackage,MyAnnotation!clazz() Painu Ljava/lang/Class;:Ljava/lang/String;
(note the use of Type Signature representation here because that's needed to distinguish between Integer.class and Integer.TYPE)


Not sure how to represent ret() yet because I don't understand annotations well enough.

mypackage,MyAnnotation!list() Painu [I:1,2,3

For array-of-string types, any commas in the strings themselves would be backslash-escaped. For two-dimensional arrays of strings we could double up the escaping, etc.

Thoughts?

Stuart.




-- Stuart Ballard, Senior Web Developer NetReach, Inc. (215) 283-2300, ext. 126 http://www.netreach.com/


_______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to