[JSR308] Wrapper types

Michael Ernst mernst at csail.mit.edu
Fri Feb 29 22:21:19 EST 2008

> Is there any plan to add wrapper types for each of these annotations.
> E.g.
> public class ReadonlyWrapper<T extends @Readonly Object>
> {
>    private final T value;
>    public ReadonlyWrapper(T value)
>    { this.value = value; }
>    public T unwrap()
>    { return value; }
> }
> which would allow encapsulating the meta data at runtime (so I could put
> these in List<Object> or call methods reflectively if the reflection API
> auto unwrapped this).

There is nothing to stop you from writing the above code, but JSR 308
doesn't take a stand on whether you should.

JSR 308 doesn't propose specific annotations like @Readonly, nor specify
their semantics.  Rather, JSR 308 extends the Java language to permit
annotations to be written in new places.  (For example, you could not write
ReadonlyWrapper without JSR 308, because @Readonly appears in the "extends"


More information about the JSR308 mailing list