[JSR308] An implementation of Subtyping for Annotations

Dr. James J. Hunt jjh at aicas.com
Thu Aug 6 08:58:50 EDT 2009

Dear Colleagues,

Please find access information for obtaining an extension of the JSR 302
Javac which supports Annotation subtyping below.  The work was done by
Christian Haack, who recently joint the aicas team.  There is a ZIP
archive with a javac.jar, the patch, and a directory with
some small tests.

  Server:   http://www.aicas.de/customers/JCP_JSR308
  Name:     JCP_JSR308
  Password: 308

This is a very small extension to the current version of the
specification that enables one to have single inheritance of annotations
and cyclical annotations as I have previously proposed.

The code checks for parsing cycles.  In my-tests/BadCycle.java, there is
a comment that explains why cyclic default definitions are problematic.
In my-tests/Avoiding-Non-Wellfoundednes.java, there is a comment
explaining what the cycle check does.

Adopting these changes would provide for subtying of annotation and the
expressive power needed to encode JML preconditions, postconditions, and
invariants in annotations.  There has been some discussion on the list
of how JML might be written.  That is not in the scope of this JSR, but
these changes would help JML to become better integrated into Java in
the future.  The other addition needed is block or statement level
annotations, but even just this would be a big boost to having a common
language for both source code level and byte code level tools.

Lex Spoon had brought up some points about readability of an annotation
encoding of JML.  There are some thoughts about how to address that too,
that will probably take too much time for Java 7.   Those ideas depend
on having inheritance and cycles in annotations too.

We still would need to look into the impact on the annotation checker
framework.  Annotations with explicit subtyping could make the framework
easier to extend, since subtyping relationship are expressed in the
annotations themselves through subclassing, instead of needing
additional rules to express subtyping.  For example, if @Immutable and
@Mutable are both subclasses of @ReadOnly, then extra rules for the type
checker would not be needed to describe the subtyping relationship.


P.S. This is a resubmission, since the original included the code as an
attachment and was therefor too large.

Dr. James J. Hunt      * CEO aicas GmbH        * Tel: +49 721 663968 22

aicas --- allerton interworks computer automated systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe     * Deutschland (Germany)
http://www.aicas.com   * Tel: +49 721 663968 0 * FAX: +49 721 663968 99

USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim
Geschäftsführer: Dr. James J. Hunt

More information about the JSR308 mailing list