Tue, 04 Jun 2013 14:17:50 -0700
8004643: Reduce javac space overhead introduced with compiler support for repeating annotations
Reviewed-by: mcimadamore, jfranck
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Lint.java Tue Jun 04 13:21:41 2013 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Lint.java Tue Jun 04 14:17:50 2013 -0700 1.3 @@ -68,19 +68,11 @@ 1.4 1.5 /** 1.6 * Returns the result of combining the values in this object with 1.7 - * the given annotations. 1.8 + * the metadata on the given symbol. 1.9 */ 1.10 - public Lint augment(Annotations annots) { 1.11 - return augmentor.augment(this, annots.getDeclarationAttributes()); 1.12 - } 1.13 - 1.14 - /** 1.15 - * Returns the result of combining the values in this object with 1.16 - * the given annotations and flags. 1.17 - */ 1.18 - public Lint augment(Annotations annots, long flags) { 1.19 - Lint l = augmentor.augment(this, annots.getDeclarationAttributes()); 1.20 - if ((flags & DEPRECATED) != 0) { 1.21 + public Lint augment(Symbol sym) { 1.22 + Lint l = augmentor.augment(this, sym.getDeclarationAttributes()); 1.23 + if (sym.isDeprecated()) { 1.24 if (l == this) 1.25 l = new Lint(this); 1.26 l.values.remove(LintCategory.DEPRECATION);
2.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Jun 04 13:21:41 2013 +0100 2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Jun 04 14:17:50 2013 -0700 2.3 @@ -32,6 +32,7 @@ 2.4 import javax.tools.JavaFileObject; 2.5 2.6 import com.sun.tools.javac.code.Type.*; 2.7 +import com.sun.tools.javac.comp.Annotate; 2.8 import com.sun.tools.javac.comp.Attr; 2.9 import com.sun.tools.javac.comp.AttrContext; 2.10 import com.sun.tools.javac.comp.Env; 2.11 @@ -74,35 +75,6 @@ 2.12 */ 2.13 public long flags() { return flags_field; } 2.14 2.15 - /** The attributes of this symbol are contained in this 2.16 - * Annotations. The Annotations instance is NOT immutable. 2.17 - */ 2.18 - public final Annotations annotations = new Annotations(this); 2.19 - 2.20 - /** An accessor method for the attributes of this symbol. 2.21 - * Attributes of class symbols should be accessed through the accessor 2.22 - * method to make sure that the class symbol is loaded. 2.23 - */ 2.24 - public List<Attribute.Compound> getRawAttributes() { 2.25 - return annotations.getDeclarationAttributes(); 2.26 - } 2.27 - 2.28 - /** An accessor method for the type attributes of this symbol. 2.29 - * Attributes of class symbols should be accessed through the accessor 2.30 - * method to make sure that the class symbol is loaded. 2.31 - */ 2.32 - public List<Attribute.TypeCompound> getRawTypeAttributes() { 2.33 - return annotations.getTypeAttributes(); 2.34 - } 2.35 - 2.36 - /** Fetch a particular annotation from a symbol. */ 2.37 - public Attribute.Compound attribute(Symbol anno) { 2.38 - for (Attribute.Compound a : getRawAttributes()) { 2.39 - if (a.type.tsym == anno) return a; 2.40 - } 2.41 - return null; 2.42 - } 2.43 - 2.44 /** The name of this symbol in Utf8 representation. 2.45 */ 2.46 public Name name; 2.47 @@ -123,6 +95,146 @@ 2.48 */ 2.49 public Type erasure_field; 2.50 2.51 + // <editor-fold defaultstate="collapsed" desc="annotations"> 2.52 + 2.53 + /** The attributes of this symbol are contained in this 2.54 + * Annotations. The Annotations instance is NOT immutable. 2.55 + */ 2.56 + protected Annotations annotations; 2.57 + 2.58 + /** An accessor method for the attributes of this symbol. 2.59 + * Attributes of class symbols should be accessed through the accessor 2.60 + * method to make sure that the class symbol is loaded. 2.61 + */ 2.62 + public List<Attribute.Compound> getRawAttributes() { 2.63 + return (annotations == null) 2.64 + ? List.<Attribute.Compound>nil() 2.65 + : annotations.getDeclarationAttributes(); 2.66 + } 2.67 + 2.68 + /** An accessor method for the type attributes of this symbol. 2.69 + * Attributes of class symbols should be accessed through the accessor 2.70 + * method to make sure that the class symbol is loaded. 2.71 + */ 2.72 + public List<Attribute.TypeCompound> getRawTypeAttributes() { 2.73 + return (annotations == null) 2.74 + ? List.<Attribute.TypeCompound>nil() 2.75 + : annotations.getTypeAttributes(); 2.76 + } 2.77 + 2.78 + /** Fetch a particular annotation from a symbol. */ 2.79 + public Attribute.Compound attribute(Symbol anno) { 2.80 + for (Attribute.Compound a : getRawAttributes()) { 2.81 + if (a.type.tsym == anno) return a; 2.82 + } 2.83 + return null; 2.84 + } 2.85 + 2.86 + public boolean annotationsPendingCompletion() { 2.87 + return annotations == null ? false : annotations.pendingCompletion(); 2.88 + } 2.89 + 2.90 + public void appendAttributes(List<Attribute.Compound> l) { 2.91 + if (l.nonEmpty()) { 2.92 + initedAnnos().append(l); 2.93 + } 2.94 + } 2.95 + 2.96 + public void appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) { 2.97 + if (l.nonEmpty()) { 2.98 + initedAnnos().appendClassInitTypeAttributes(l); 2.99 + } 2.100 + } 2.101 + 2.102 + public void appendInitTypeAttributes(List<Attribute.TypeCompound> l) { 2.103 + if (l.nonEmpty()) { 2.104 + initedAnnos().appendInitTypeAttributes(l); 2.105 + } 2.106 + } 2.107 + 2.108 + public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) { 2.109 + initedAnnos().appendTypeAttributesWithCompletion(ctx); 2.110 + } 2.111 + 2.112 + public void appendUniqueTypeAttributes(List<Attribute.TypeCompound> l) { 2.113 + if (l.nonEmpty()) { 2.114 + initedAnnos().appendUniqueTypes(l); 2.115 + } 2.116 + } 2.117 + 2.118 + public List<Attribute.TypeCompound> getClassInitTypeAttributes() { 2.119 + return (annotations == null) 2.120 + ? List.<Attribute.TypeCompound>nil() 2.121 + : annotations.getClassInitTypeAttributes(); 2.122 + } 2.123 + 2.124 + public List<Attribute.TypeCompound> getInitTypeAttributes() { 2.125 + return (annotations == null) 2.126 + ? List.<Attribute.TypeCompound>nil() 2.127 + : annotations.getInitTypeAttributes(); 2.128 + } 2.129 + 2.130 + public List<Attribute.Compound> getDeclarationAttributes() { 2.131 + return (annotations == null) 2.132 + ? List.<Attribute.Compound>nil() 2.133 + : annotations.getDeclarationAttributes(); 2.134 + } 2.135 + 2.136 + public boolean hasAnnotations() { 2.137 + return (annotations != null && !annotations.isEmpty()); 2.138 + } 2.139 + 2.140 + public boolean hasTypeAnnotations() { 2.141 + return (annotations != null && !annotations.isTypesEmpty()); 2.142 + } 2.143 + 2.144 + public void prependAttributes(List<Attribute.Compound> l) { 2.145 + if (l.nonEmpty()) { 2.146 + initedAnnos().prepend(l); 2.147 + } 2.148 + } 2.149 + 2.150 + public void resetAnnotations() { 2.151 + initedAnnos().reset(); 2.152 + } 2.153 + 2.154 + public void setAttributes(Symbol other) { 2.155 + if (annotations != null || other.annotations != null) { 2.156 + initedAnnos().setAttributes(other.annotations); 2.157 + } 2.158 + } 2.159 + 2.160 + public void setDeclarationAttributes(List<Attribute.Compound> a) { 2.161 + if (annotations != null || a.nonEmpty()) { 2.162 + initedAnnos().setDeclarationAttributes(a); 2.163 + } 2.164 + } 2.165 + 2.166 + public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) { 2.167 + initedAnnos().setDeclarationAttributesWithCompletion(ctx); 2.168 + } 2.169 + 2.170 + public void setTypeAttributes(List<Attribute.TypeCompound> a) { 2.171 + if (annotations != null || a.nonEmpty()) { 2.172 + if (annotations == null) 2.173 + annotations = new Annotations(this); 2.174 + annotations.setTypeAttributes(a); 2.175 + } 2.176 + } 2.177 + 2.178 + private Annotations initedAnnos() { 2.179 + if (annotations == null) 2.180 + annotations = new Annotations(this); 2.181 + return annotations; 2.182 + } 2.183 + 2.184 + /** This method is intended for debugging only. */ 2.185 + public Annotations getAnnotations() { 2.186 + return annotations; 2.187 + } 2.188 + 2.189 + // </editor-fold> 2.190 + 2.191 /** Construct a symbol with given kind, flags, name, type and owner. 2.192 */ 2.193 public Symbol(int kind, long flags, Name name, Type type, Symbol owner) { 2.194 @@ -207,6 +319,10 @@ 2.195 } 2.196 } 2.197 2.198 + public boolean isDeprecated() { 2.199 + return (flags_field & DEPRECATED) != 0; 2.200 + } 2.201 + 2.202 public boolean isStatic() { 2.203 return 2.204 (flags() & STATIC) != 0 || 2.205 @@ -726,8 +842,9 @@ 2.206 } 2.207 2.208 private void mergeAttributes() { 2.209 - if (annotations.isEmpty() && 2.210 - !package_info.annotations.isEmpty()) { 2.211 + if (annotations == null && 2.212 + package_info.annotations != null) { 2.213 + annotations = new Annotations(this); 2.214 annotations.setAttributes(package_info.annotations); 2.215 } 2.216 }
3.1 --- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Jun 04 13:21:41 2013 +0100 3.2 +++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Jun 04 14:17:50 2013 -0700 3.3 @@ -271,8 +271,8 @@ 3.4 } 3.5 } 3.6 3.7 - sym.annotations.reset(); 3.8 - sym.annotations.setDeclarationAttributes(declAnnos.toList()); 3.9 + sym.resetAnnotations(); 3.10 + sym.setDeclarationAttributes(declAnnos.toList()); 3.11 3.12 if (typeAnnos.isEmpty()) { 3.13 return; 3.14 @@ -284,7 +284,7 @@ 3.15 // When type is null, put the type annotations to the symbol. 3.16 // This is used for constructor return annotations, for which 3.17 // no appropriate type exists. 3.18 - sym.annotations.appendUniqueTypes(typeAnnotations); 3.19 + sym.appendUniqueTypeAttributes(typeAnnotations); 3.20 return; 3.21 } 3.22 3.23 @@ -318,7 +318,7 @@ 3.24 sym.type = type; 3.25 } 3.26 3.27 - sym.annotations.appendUniqueTypes(typeAnnotations); 3.28 + sym.appendUniqueTypeAttributes(typeAnnotations); 3.29 3.30 if (sym.getKind() == ElementKind.PARAMETER || 3.31 sym.getKind() == ElementKind.LOCAL_VARIABLE || 3.32 @@ -326,7 +326,7 @@ 3.33 sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { 3.34 // Make sure all type annotations from the symbol are also 3.35 // on the owner. 3.36 - sym.owner.annotations.appendUniqueTypes(sym.getRawTypeAttributes()); 3.37 + sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes()); 3.38 } 3.39 } 3.40 3.41 @@ -855,7 +855,7 @@ 3.42 Assert.error("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind()); 3.43 } 3.44 if (v.getKind() != ElementKind.FIELD) { 3.45 - v.owner.annotations.appendUniqueTypes(v.getRawTypeAttributes()); 3.46 + v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes()); 3.47 } 3.48 return; 3.49
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jun 04 13:21:41 2013 +0100 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jun 04 14:17:50 2013 -0700 4.3 @@ -757,11 +757,10 @@ 4.4 // env.info.enclVar.attributes_field might not yet have been evaluated, and so might be 4.5 // null. In that case, calling augment will throw an NPE. To avoid this, for now we 4.6 // revert to the jdk 6 behavior and ignore the (unevaluated) attributes. 4.7 - if (env.info.enclVar.annotations.pendingCompletion()) { 4.8 + if (env.info.enclVar.annotationsPendingCompletion()) { 4.9 env.info.lint = lintEnv.info.lint; 4.10 } else { 4.11 - env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.annotations, 4.12 - env.info.enclVar.flags()); 4.13 + env.info.lint = lintEnv.info.lint.augment(env.info.enclVar); 4.14 } 4.15 4.16 Lint prevLint = chk.setLint(env.info.lint); 4.17 @@ -881,7 +880,7 @@ 4.18 MethodSymbol m = tree.sym; 4.19 boolean isDefaultMethod = (m.flags() & DEFAULT) != 0; 4.20 4.21 - Lint lint = env.info.lint.augment(m.annotations, m.flags()); 4.22 + Lint lint = env.info.lint.augment(m); 4.23 Lint prevLint = chk.setLint(lint); 4.24 MethodSymbol prevMethod = chk.setMethod(m); 4.25 try { 4.26 @@ -1052,7 +1051,7 @@ 4.27 } 4.28 4.29 VarSymbol v = tree.sym; 4.30 - Lint lint = env.info.lint.augment(v.annotations, v.flags()); 4.31 + Lint lint = env.info.lint.augment(v); 4.32 Lint prevLint = chk.setLint(lint); 4.33 4.34 // Check that the variable's declared type is well-formed. 4.35 @@ -1121,9 +1120,9 @@ 4.36 ClassSymbol cs = (ClassSymbol)env.info.scope.owner; 4.37 List<Attribute.TypeCompound> tas = localEnv.info.scope.owner.getRawTypeAttributes(); 4.38 if ((tree.flags & STATIC) != 0) { 4.39 - cs.annotations.appendClassInitTypeAttributes(tas); 4.40 + cs.appendClassInitTypeAttributes(tas); 4.41 } else { 4.42 - cs.annotations.appendInitTypeAttributes(tas); 4.43 + cs.appendInitTypeAttributes(tas); 4.44 } 4.45 } 4.46 4.47 @@ -4118,7 +4117,7 @@ 4.48 lintEnv = lintEnv.next; 4.49 4.50 // Having found the enclosing lint value, we can initialize the lint value for this class 4.51 - env.info.lint = lintEnv.info.lint.augment(c.annotations, c.flags()); 4.52 + env.info.lint = lintEnv.info.lint.augment(c); 4.53 4.54 Lint prevLint = chk.setLint(env.info.lint); 4.55 JavaFileObject prev = log.useSource(c.sourcefile);
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Enter.java Tue Jun 04 13:21:41 2013 +0100 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Tue Jun 04 14:17:50 2013 -0700 5.3 @@ -161,7 +161,7 @@ 5.4 Env<AttrContext> lintEnv = localEnv; 5.5 while (lintEnv.info.lint == null) 5.6 lintEnv = lintEnv.next; 5.7 - localEnv.info.lint = lintEnv.info.lint.augment(sym.annotations, sym.flags()); 5.8 + localEnv.info.lint = lintEnv.info.lint.augment(sym); 5.9 return localEnv; 5.10 } 5.11
6.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Jun 04 13:21:41 2013 +0100 6.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Jun 04 14:17:50 2013 -0700 6.3 @@ -434,7 +434,7 @@ 6.4 Lint lintPrev = lint; 6.5 6.6 pendingExits = new ListBuffer<PendingExit>(); 6.7 - lint = lint.augment(tree.sym.annotations); 6.8 + lint = lint.augment(tree.sym); 6.9 6.10 try { 6.11 // process all the static initializers 6.12 @@ -470,7 +470,7 @@ 6.13 if (tree.body == null) return; 6.14 Lint lintPrev = lint; 6.15 6.16 - lint = lint.augment(tree.sym.annotations); 6.17 + lint = lint.augment(tree.sym); 6.18 6.19 Assert.check(pendingExits.isEmpty()); 6.20 6.21 @@ -496,7 +496,7 @@ 6.22 public void visitVarDef(JCVariableDecl tree) { 6.23 if (tree.init != null) { 6.24 Lint lintPrev = lint; 6.25 - lint = lint.augment(tree.sym.annotations); 6.26 + lint = lint.augment(tree.sym); 6.27 try{ 6.28 scan(tree.init); 6.29 } finally { 6.30 @@ -836,7 +836,7 @@ 6.31 } 6.32 classDef = tree; 6.33 thrown = List.nil(); 6.34 - lint = lint.augment(tree.sym.annotations); 6.35 + lint = lint.augment(tree.sym); 6.36 6.37 try { 6.38 // process all the static initializers 6.39 @@ -916,7 +916,7 @@ 6.40 List<Type> mthrown = tree.sym.type.getThrownTypes(); 6.41 Lint lintPrev = lint; 6.42 6.43 - lint = lint.augment(tree.sym.annotations); 6.44 + lint = lint.augment(tree.sym); 6.45 6.46 Assert.check(pendingExits.isEmpty()); 6.47 6.48 @@ -955,7 +955,7 @@ 6.49 public void visitVarDef(JCVariableDecl tree) { 6.50 if (tree.init != null) { 6.51 Lint lintPrev = lint; 6.52 - lint = lint.augment(tree.sym.annotations); 6.53 + lint = lint.augment(tree.sym); 6.54 try{ 6.55 scan(tree.init); 6.56 } finally { 6.57 @@ -1580,7 +1580,7 @@ 6.58 firstadr = nextadr; 6.59 } 6.60 classDef = tree; 6.61 - lint = lint.augment(tree.sym.annotations); 6.62 + lint = lint.augment(tree.sym); 6.63 6.64 try { 6.65 // define all the static fields 6.66 @@ -1648,7 +1648,7 @@ 6.67 int returnadrPrev = returnadr; 6.68 Lint lintPrev = lint; 6.69 6.70 - lint = lint.augment(tree.sym.annotations); 6.71 + lint = lint.augment(tree.sym); 6.72 6.73 Assert.check(pendingExits.isEmpty()); 6.74 6.75 @@ -1700,7 +1700,7 @@ 6.76 if (track && tree.sym.owner.kind == MTH) newVar(tree.sym); 6.77 if (tree.init != null) { 6.78 Lint lintPrev = lint; 6.79 - lint = lint.augment(tree.sym.annotations); 6.80 + lint = lint.augment(tree.sym); 6.81 try{ 6.82 scanExpr(tree.init); 6.83 if (track) letInit(tree.pos(), tree.sym);
7.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Jun 04 13:21:41 2013 +0100 7.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Jun 04 14:17:50 2013 -0700 7.3 @@ -249,8 +249,8 @@ 7.4 } 7.5 } 7.6 if (lambdaTypeAnnos.nonEmpty()) { 7.7 - owner.annotations.setTypeAttributes(ownerTypeAnnos.toList()); 7.8 - sym.annotations.setTypeAttributes(lambdaTypeAnnos.toList()); 7.9 + owner.setTypeAttributes(ownerTypeAnnos.toList()); 7.10 + sym.setTypeAttributes(lambdaTypeAnnos.toList()); 7.11 } 7.12 } 7.13 7.14 @@ -389,15 +389,15 @@ 7.15 if (lambdaContext.getSymbolMap(PARAM).containsKey(tree.sym)) { 7.16 Symbol translatedSym = lambdaContext.getSymbolMap(PARAM).get(tree.sym); 7.17 result = make.Ident(translatedSym).setType(tree.type); 7.18 - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); 7.19 + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); 7.20 } else if (lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) { 7.21 Symbol translatedSym = lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym); 7.22 result = make.Ident(translatedSym).setType(tree.type); 7.23 - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); 7.24 + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); 7.25 } else if (lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) { 7.26 Symbol translatedSym = lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym); 7.27 result = make.Ident(translatedSym).setType(translatedSym.type); 7.28 - translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes()); 7.29 + translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes()); 7.30 } else if (lambdaContext.getSymbolMap(CAPTURED_VAR).containsKey(tree.sym)) { 7.31 Symbol translatedSym = lambdaContext.getSymbolMap(CAPTURED_VAR).get(tree.sym); 7.32 result = make.Ident(translatedSym).setType(tree.type); 7.33 @@ -1715,8 +1715,8 @@ 7.34 ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); 7.35 } 7.36 if (ret != sym) { 7.37 - ret.annotations.setDeclarationAttributes(sym.getRawAttributes()); 7.38 - ret.annotations.setTypeAttributes(sym.getRawTypeAttributes()); 7.39 + ret.setDeclarationAttributes(sym.getRawAttributes()); 7.40 + ret.setTypeAttributes(sym.getRawTypeAttributes()); 7.41 } 7.42 return ret; 7.43 }
8.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Jun 04 13:21:41 2013 +0100 8.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Jun 04 14:17:50 2013 -0700 8.3 @@ -2360,7 +2360,7 @@ 8.4 null, List.<JCExpression>nil(), List.<JCTree>nil()); 8.5 ClassSymbol c = tree.packge.package_info; 8.6 c.flags_field |= flags; 8.7 - c.annotations.setAttributes(tree.packge.annotations); 8.8 + c.setAttributes(tree.packge); 8.9 ClassType ctype = (ClassType) c.type; 8.10 ctype.supertype_field = syms.objectType; 8.11 ctype.interfaces_field = List.nil(); 8.12 @@ -2378,7 +2378,7 @@ 8.13 return tree.packageAnnotations.nonEmpty(); 8.14 case NONEMPTY: 8.15 for (Attribute.Compound a : 8.16 - tree.packge.annotations.getDeclarationAttributes()) { 8.17 + tree.packge.getDeclarationAttributes()) { 8.18 Attribute.RetentionPolicy p = types.getRetention(a); 8.19 if (p != Attribute.RetentionPolicy.SOURCE) 8.20 return true;
9.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Jun 04 13:21:41 2013 +0100 9.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Jun 04 14:17:50 2013 -0700 9.3 @@ -712,7 +712,7 @@ 9.4 9.5 public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) { 9.6 Env<AttrContext> mEnv = methodEnv(tree, env); 9.7 - mEnv.info.lint = mEnv.info.lint.augment(tree.sym.annotations, tree.sym.flags()); 9.8 + mEnv.info.lint = mEnv.info.lint.augment(tree.sym); 9.9 for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty(); l = l.tail) 9.10 mEnv.info.scope.enterIfAbsent(l.head.type.tsym); 9.11 for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) 9.12 @@ -753,7 +753,7 @@ 9.13 return; 9.14 } 9.15 if (s.kind != PCK) { 9.16 - s.annotations.reset(); // mark Annotations as incomplete for now 9.17 + s.resetAnnotations(); // mark Annotations as incomplete for now 9.18 } 9.19 annotate.normal(new Annotate.Annotator() { 9.20 @Override 9.21 @@ -763,10 +763,10 @@ 9.22 9.23 @Override 9.24 public void enterAnnotation() { 9.25 - Assert.check(s.kind == PCK || s.annotations.pendingCompletion()); 9.26 + Assert.check(s.kind == PCK || s.annotationsPendingCompletion()); 9.27 JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile); 9.28 try { 9.29 - if (!s.annotations.isEmpty() && 9.30 + if (s.hasAnnotations() && 9.31 annotations.nonEmpty()) 9.32 log.error(annotations.head.pos, 9.33 "already.annotated", 9.34 @@ -832,7 +832,7 @@ 9.35 } 9.36 } 9.37 9.38 - s.annotations.setDeclarationAttributesWithCompletion( 9.39 + s.setDeclarationAttributesWithCompletion( 9.40 annotate.new AnnotateRepeatedContext<Attribute.Compound>(env, annotated, pos, log, false)); 9.41 } 9.42 9.43 @@ -1107,7 +1107,7 @@ 9.44 } 9.45 9.46 if (s != null) { 9.47 - s.annotations.appendTypeAttributesWithCompletion( 9.48 + s.appendTypeAttributesWithCompletion( 9.49 annotate.new AnnotateRepeatedContext<Attribute.TypeCompound>(env, annotated, pos, log, true)); 9.50 } 9.51 }
10.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Jun 04 13:21:41 2013 +0100 10.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Jun 04 14:17:50 2013 -0700 10.3 @@ -262,9 +262,7 @@ 10.4 * be applied to method addOverrideBridgesIfNeeded 10.5 */ 10.6 bridge.params = createBridgeParams(impl, bridge, bridgeType); 10.7 - if (impl.annotations != null) { 10.8 - bridge.annotations.setAttributes(impl.annotations); 10.9 - } 10.10 + bridge.setAttributes(impl); 10.11 10.12 if (!hypothetical) { 10.13 JCMethodDecl md = make.MethodDef(bridge, null); 10.14 @@ -311,9 +309,7 @@ 10.15 while (implParams.nonEmpty() && argTypes.nonEmpty()) { 10.16 VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC, 10.17 implParams.head.name, argTypes.head, bridge); 10.18 - if (implParams.head.annotations != null) { 10.19 - param.annotations.setAttributes(implParams.head.annotations); 10.20 - } 10.21 + param.setAttributes(implParams.head); 10.22 bridgeParams = bridgeParams.append(param); 10.23 implParams = implParams.tail; 10.24 argTypes = argTypes.tail;
11.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Jun 04 13:21:41 2013 +0100 11.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Jun 04 14:17:50 2013 -0700 11.3 @@ -1896,12 +1896,11 @@ 11.4 JavaFileObject previousClassFile = currentClassFile; 11.5 try { 11.6 currentClassFile = classFile; 11.7 - Annotations annotations = sym.annotations; 11.8 List<Attribute.Compound> newList = deproxyCompoundList(l); 11.9 - if (annotations.pendingCompletion()) { 11.10 - annotations.setDeclarationAttributes(newList); 11.11 + if (sym.annotationsPendingCompletion()) { 11.12 + sym.setDeclarationAttributes(newList); 11.13 } else { 11.14 - annotations.append(newList); 11.15 + sym.appendAttributes(newList); 11.16 } 11.17 } finally { 11.18 currentClassFile = previousClassFile; 11.19 @@ -1935,7 +1934,7 @@ 11.20 try { 11.21 currentClassFile = classFile; 11.22 List<Attribute.TypeCompound> newList = deproxyTypeCompoundList(proxies); 11.23 - sym.annotations.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes())); 11.24 + sym.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes())); 11.25 } finally { 11.26 currentClassFile = previousClassFile; 11.27 }
12.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Jun 04 13:21:41 2013 +0100 12.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Jun 04 14:17:50 2013 -0700 12.3 @@ -1960,8 +1960,7 @@ 12.4 } 12.5 12.6 private void fillLocalVarPosition(LocalVar lv) { 12.7 - if (lv == null || lv.sym == null 12.8 - || lv.sym.annotations.isTypesEmpty()) 12.9 + if (lv == null || lv.sym == null || !lv.sym.hasTypeAnnotations()) 12.10 return; 12.11 for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) { 12.12 TypeAnnotationPosition p = ta.position; 12.13 @@ -1979,7 +1978,7 @@ 12.14 for (int i = 0; i < varBufferSize; ++i) { 12.15 LocalVar lv = varBuffer[i]; 12.16 if (lv == null || lv.sym == null 12.17 - || lv.sym.annotations.isTypesEmpty() 12.18 + || !lv.sym.hasTypeAnnotations() 12.19 || !lv.sym.isExceptionParameter()) 12.20 continue; 12.21 12.22 @@ -2028,7 +2027,7 @@ 12.23 // 2) it is an exception type and it contains type annotations 12.24 if (!varDebugInfo && 12.25 (!var.sym.isExceptionParameter() || 12.26 - var.sym.annotations.isTypesEmpty())) return; 12.27 + var.sym.hasTypeAnnotations())) return; 12.28 if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; 12.29 if (varBuffer == null) 12.30 varBuffer = new LocalVar[20];
13.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Jun 04 13:21:41 2013 +0100 13.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Jun 04 14:17:50 2013 -0700 13.3 @@ -518,7 +518,7 @@ 13.4 // Insert any instance initializers into all constructors. 13.5 if (initCode.length() != 0) { 13.6 List<JCStatement> inits = initCode.toList(); 13.7 - initTAs.addAll(c.annotations.getInitTypeAttributes()); 13.8 + initTAs.addAll(c.getInitTypeAttributes()); 13.9 List<Attribute.TypeCompound> initTAlist = initTAs.toList(); 13.10 for (JCTree t : methodDefs) { 13.11 normalizeMethod((JCMethodDecl)t, inits, initTAlist); 13.12 @@ -541,9 +541,9 @@ 13.13 methodDefs.append(make.MethodDef(clinit, block)); 13.14 13.15 if (!clinitTAs.isEmpty()) 13.16 - clinit.annotations.appendUniqueTypes(clinitTAs.toList()); 13.17 - if (!c.annotations.getClassInitTypeAttributes().isEmpty()) 13.18 - clinit.annotations.appendUniqueTypes(c.annotations.getClassInitTypeAttributes()); 13.19 + clinit.appendUniqueTypeAttributes(clinitTAs.toList()); 13.20 + if (!c.getClassInitTypeAttributes().isEmpty()) 13.21 + clinit.appendUniqueTypeAttributes(c.getClassInitTypeAttributes()); 13.22 } 13.23 // Return all method definitions. 13.24 return methodDefs.toList(); 13.25 @@ -560,7 +560,7 @@ 13.26 nonfieldTAs.add(ta); 13.27 } 13.28 } 13.29 - sym.annotations.setTypeAttributes(fieldTAs.toList()); 13.30 + sym.setTypeAttributes(fieldTAs.toList()); 13.31 return nonfieldTAs.toList(); 13.32 } 13.33 13.34 @@ -618,7 +618,7 @@ 13.35 if (md.body.endpos == Position.NOPOS) 13.36 md.body.endpos = TreeInfo.endPos(md.body.stats.last()); 13.37 13.38 - md.sym.annotations.appendUniqueTypes(initTAs); 13.39 + md.sym.appendUniqueTypeAttributes(initTAs); 13.40 } 13.41 } 13.42
14.1 --- a/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java Tue Jun 04 13:21:41 2013 +0100 14.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java Tue Jun 04 14:17:50 2013 -0700 14.3 @@ -160,7 +160,7 @@ 14.4 for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { 14.5 if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) 14.6 return true; 14.7 - for (Attribute.Compound a: i.sym.annotations.getDeclarationAttributes()) { 14.8 + for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { 14.9 if (a.type.tsym == syms.nativeHeaderType.tsym) 14.10 return true; 14.11 }
15.1 --- a/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Tue Jun 04 13:21:41 2013 +0100 15.2 +++ b/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Tue Jun 04 14:17:50 2013 -0700 15.3 @@ -1,5 +1,5 @@ 15.4 /* 15.5 - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. 15.6 + * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. 15.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.8 * 15.9 * This code is free software; you can redistribute it and/or modify it 15.10 @@ -225,11 +225,11 @@ 15.11 } 15.12 ClassSymbol cs = (ClassSymbol) sym; 15.13 if (addLegacyAnnotation) { 15.14 - cs.annotations.prepend(List.of(proprietaryAnno)); 15.15 + cs.prependAttributes(List.of(proprietaryAnno)); 15.16 } 15.17 int p = profiles.getProfile(cs.fullname.toString().replace(".", "/")); 15.18 if (0 < p && p < profileAnnos.length) 15.19 - cs.annotations.prepend(List.of(profileAnnos[p])); 15.20 + cs.prependAttributes(List.of(profileAnnos[p])); 15.21 writeClass(pool, cs, writer); 15.22 } 15.23
16.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Jun 04 13:21:41 2013 +0100 16.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Jun 04 14:17:50 2013 -0700 16.3 @@ -1131,6 +1131,14 @@ 16.4 16.5 private static class TypeAnnotationFinder extends TreeScanner { 16.6 public boolean foundTypeAnno = false; 16.7 + 16.8 + @Override 16.9 + public void scan(JCTree tree) { 16.10 + if (foundTypeAnno || tree == null) 16.11 + return; 16.12 + super.scan(tree); 16.13 + } 16.14 + 16.15 public void visitAnnotation(JCAnnotation tree) { 16.16 foundTypeAnno = foundTypeAnno || tree.hasTag(TYPE_ANNOTATION); 16.17 }
17.1 --- a/test/tools/javac/lib/DPrinter.java Tue Jun 04 13:21:41 2013 +0100 17.2 +++ b/test/tools/javac/lib/DPrinter.java Tue Jun 04 14:17:50 2013 -0700 17.3 @@ -403,7 +403,7 @@ 17.4 printType("type", sym.type, Details.SUMMARY); 17.5 printType("erasure", sym.erasure_field, Details.SUMMARY); 17.6 sym.accept(symVisitor, null); 17.7 - printAnnotations("annotations", sym.annotations, Details.SUMMARY); 17.8 + printAnnotations("annotations", sym.getAnnotations(), Details.SUMMARY); 17.9 indent(-1); 17.10 } 17.11 }