[JSR308] array-valued annotations

Tom Ball Tom.Ball at Sun.COM
Mon Jan 29 22:15:20 EST 2007

David Wagner wrote:
> Ted Neward writes:
>> I think we're trying to decide if (a) an annotation on a local variable
>> declaration is part of its type signature, [...]
>> Assuming (a) is false, and that the annotations are not part of the type
>> signature, [...]
> I think that speaking of "the type system" is misleading.
> There is not just one type system; there may be multiple type systems
> floating around.
> First, there is the base Java type system (i.e., the type system that
> results after erasing the annotations).  The base Java type system is
> what is enforced by "javac" and what is specified in the JLS.
> Second, there is the type system enforced by the plug-in that processes
> these annotations.  In many cases, the expectation is that there will be
> some plug-in or some source code analysis tool that will inspect the
> annotations and use the annotations to reject or warn about certain code
> constructs.  In many cases, this may amount to the plug-in specifying and
> enforcing a strictly more restrictive type system than the base Java type
> system.
> For instance, in the code:
>     @Nonnull Object[@Nonnull] a;
> the type of 'a' in the base Java type system is Object[], while the
> type in the plug-in's type system might be "a nonnull reference to an
> array holding nonnull references to Object".
> Note that plug-ins can enforce a more restrictive type system even though
> they cannot change the underlying base Java type system.
> One of the purposes of JSR308 annotations is to make it possible for
> plug-in writers to design and enforce richer type systems -- all without
> changing the base Java type system.

It sounds like we are in agreement, but I prefer the term "contract" 
(from Eiffel's "Design By Contract") to "type" when using metadata to 
provide additional information to error-checkers regarding an API.  My 
guess is that the JSR's spec will be less confusing by keeping these 
concepts separate.


More information about the JSR308 mailing list