On the impl of AnnotatedType

Jonathan Gibbons jonathan.gibbons at oracle.com
Thu Jan 24 19:25:32 PST 2013


On 01/24/2013 09:40 AM, Werner Dietl wrote:
> It looks like the prevailing opinion is to try the anonymous subtype approach.
> Should I or do you want to do this in the type-annotations repo or in TL?
>
> cu, WMD.

My enthusiasm for the anon subtype approach is rapidly diminishing.

A scan of the classes reveals 28 subtypes of Type, which either require 
a corresponding anon subtype or a sufficiently good analysis to 
determine why such a subtype is not required. Of these 28 types, 8 are 
already anon subtypes, dealing with const values, varargs etc.

The following classes are all subtypes of com.sun.tools.javac.code.Type:

build/classes/com/sun/tools/javac/code/Type$AnnotatedType.class
build/classes/com/sun/tools/javac/code/Type$MethodType.class
build/classes/com/sun/tools/javac/code/Type$ArrayType.class
build/classes/com/sun/tools/javac/code/Symtab$3.class
build/classes/com/sun/tools/javac/code/Type$IntersectionClassType.class
build/classes/com/sun/tools/javac/code/Type$WildcardType.class
build/classes/com/sun/tools/javac/code/Type$1.class
build/classes/com/sun/tools/javac/code/Type$JCNoType.class
build/classes/com/sun/tools/javac/code/Type$ErasedClassType.class
build/classes/com/sun/tools/javac/code/Type$BottomType.class
build/classes/com/sun/tools/javac/code/Type$UnionClassType.class
build/classes/com/sun/tools/javac/code/Type$ForAll.class
build/classes/com/sun/tools/javac/code/Type$ArrayType$1.class
build/classes/com/sun/tools/javac/code/Type$UndetVar.class
build/classes/com/sun/tools/javac/code/Type$PackageType.class
build/classes/com/sun/tools/javac/code/Type$ErrorType.class
build/classes/com/sun/tools/javac/code/Type$TypeVar.class
build/classes/com/sun/tools/javac/code/Type$ClassType$1.class
build/classes/com/sun/tools/javac/code/Type$DelegatedType.class
build/classes/com/sun/tools/javac/code/Type$ClassType.class
build/classes/com/sun/tools/javac/code/Type.class
build/classes/com/sun/tools/javac/code/Type$CapturedType.class
build/classes/com/sun/tools/javac/comp/MemberEnter$Synthesizer$2.class
build/classes/com/sun/tools/javac/comp/MemberEnter$7.class
build/classes/com/sun/tools/javac/comp/MemberEnter$Synthesizer$1.class
build/classes/com/sun/tools/javac/comp/DeferredAttr$DeferredType.class
build/classes/com/sun/tools/javac/jvm/ClassReader$1.class
build/classes/com/sun/tools/javac/jvm/UninitializedType.class

Yesterday, Joel wrote:
> - The reason I want to move from the delegation model is that I need to further subdivide AnnotatedType into AnnotatedTypeVariable, AnnotatedWildcardType, AnnotatedParameterizedType and AnnotatedArrayType. While you can have AnnotatedType implement the union of all the functionality of the above and do dispatching this feels very brittle. If we move to a subtype model instead it should be easy and type-safe to provide the functionality in the subclasses where we know for a fact that the base type is for example a WildcardType.
  So, Joel, 4 named subtypes vs 28 anon subtypes ...

-- Jon


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/type-annotations-dev/attachments/20130124/93425694/attachment.html 


More information about the type-annotations-dev mailing list