On the impl of AnnotatedType
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Jan 23 15:07:09 PST 2013
On the impl of AnnotatedType
First, note that there are 3 types called AnnotatedType, so we need to
be careful to distinguish them.
1. javax.lang.model.type.AnnotatedType
This is a public JCP-controlled interface in the javax.lang.model package.
2. com.sun.javadoc.AnnotatedType
This is a public interface, part of the Doclet API.
3. com.sun.tools.javac.code.Type.AnnotatedType
This is an internal impl class only.
So, the jx.l.m class exists because we do not want to add extra methods
to the supertype interface, jx.l.m.TypeMirror. Likewise,
c.s.j.AnnotatedType exists because we don't want to add methods to
c.s.j.Type.
But, these reasons do not apply to c.s.t.j.code.Type, and we can add
methods to that as we choose. So that leads us to the impl choice we now
have: whether to use a delegation model or anon-subtype model to impl
the jx.l.m.t.AT.
Within javac, we are not so constrained to avoid code.Type either, and
it would be nice, as far as possible, to add virtual methods on
code.Type to avoid unnecessary instanceof and cast tests within the
javac code.
As for delegation vs anon-subtyping, the more we can hide that choice
behind methods on Type, the less it matters. I am concerned, in the
webrevs I've done so far, at the number of anon-subtypes required, such
that this is not a slam-dunk choice. But the delegation approach
requires a fair-amount of undelegating to the underlying type as well.
-- Jon
More information about the type-annotations-dev
mailing list