[JSR308] Annotations on String and primitive literals?

Eugene Kuleshov eu at javatx.org
Fri May 9 03:07:44 EDT 2008

  In this particular case, string literal can be considered as a 
meta-type, and in this case annotation can be added to a cast, e.g.

  URL resource = MyClass.class.getResource((@Resource String) 

  There is some discussion around that in [1].



Neal Gafter wrote:
> Jsr308 is adding support for annotations on types.  Classes are 
> types.  String literals are not types.
> On Thu, May 8, 2008 at 10:44 AM, Artemus Harper <subanark at gmail.com 
> <mailto:subanark at gmail.com>> wrote:
>     Is there any reason that annotations are permitted on class
>     literals, but not on String, or primitive literals.
>     E.g.
>     I might want to have:
>     URL resource = MyClass.class.getResource(@Resource "someResource");
>     Where the Resource checker would ensure that there is a resource
>     called "someResource" relative to MyClass.
>     -- 
>     Artemus Harper

More information about the JSR308 mailing list