1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Tue Oct 15 22:15:35 2013 +0200 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Tue Oct 15 15:57:13 2013 -0700 1.3 @@ -225,6 +225,10 @@ 1.4 return this; 1.5 } 1.6 1.7 + public Type annotatedType(List<Attribute.TypeCompound> annos) { 1.8 + return new AnnotatedType(annos, this); 1.9 + } 1.10 + 1.11 public boolean isAnnotated() { 1.12 return false; 1.13 } 1.14 @@ -1818,25 +1822,19 @@ 1.15 javax.lang.model.type.WildcardType { 1.16 /** The type annotations on this type. 1.17 */ 1.18 - public List<Attribute.TypeCompound> typeAnnotations; 1.19 + private List<Attribute.TypeCompound> typeAnnotations; 1.20 1.21 /** The underlying type that is annotated. 1.22 */ 1.23 - public Type underlyingType; 1.24 + private Type underlyingType; 1.25 1.26 - public AnnotatedType(Type underlyingType) { 1.27 - super(underlyingType.tsym); 1.28 - this.typeAnnotations = List.nil(); 1.29 - this.underlyingType = underlyingType; 1.30 - Assert.check(!underlyingType.isAnnotated(), 1.31 - "Can't annotate already annotated type: " + underlyingType); 1.32 - } 1.33 - 1.34 - public AnnotatedType(List<Attribute.TypeCompound> typeAnnotations, 1.35 + protected AnnotatedType(List<Attribute.TypeCompound> typeAnnotations, 1.36 Type underlyingType) { 1.37 super(underlyingType.tsym); 1.38 this.typeAnnotations = typeAnnotations; 1.39 this.underlyingType = underlyingType; 1.40 + Assert.check(typeAnnotations != null && typeAnnotations.nonEmpty(), 1.41 + "Can't create AnnotatedType without annotations: " + underlyingType); 1.42 Assert.check(!underlyingType.isAnnotated(), 1.43 "Can't annotate already annotated type: " + underlyingType + 1.44 "; adding: " + typeAnnotations); 1.45 @@ -1977,10 +1975,8 @@ 1.46 public TypeMirror getComponentType() { return ((ArrayType)underlyingType).getComponentType(); } 1.47 1.48 // The result is an ArrayType, but only in the model sense, not the Type sense. 1.49 - public AnnotatedType makeVarargs() { 1.50 - AnnotatedType atype = new AnnotatedType(((ArrayType)underlyingType).makeVarargs()); 1.51 - atype.typeAnnotations = this.typeAnnotations; 1.52 - return atype; 1.53 + public Type makeVarargs() { 1.54 + return ((ArrayType) underlyingType).makeVarargs().annotatedType(typeAnnotations); 1.55 } 1.56 1.57 @Override