8004643: Reduce javac space overhead introduced with compiler support for repeating annotations
Reviewed-by: mcimadamore, jfranck
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java Tue Jun 04 14:17:50 2013 -0700
@@ -68,19 +68,11 @@
/**
* Returns the result of combining the values in this object with
- * the given annotations.
+ * the metadata on the given symbol.
*/
- public Lint augment(Annotations annots) {
- return augmentor.augment(this, annots.getDeclarationAttributes());
- }
-
- /**
- * Returns the result of combining the values in this object with
- * the given annotations and flags.
- */
- public Lint augment(Annotations annots, long flags) {
- Lint l = augmentor.augment(this, annots.getDeclarationAttributes());
- if ((flags & DEPRECATED) != 0) {
+ public Lint augment(Symbol sym) {
+ Lint l = augmentor.augment(this, sym.getDeclarationAttributes());
+ if (sym.isDeprecated()) {
if (l == this)
l = new Lint(this);
l.values.remove(LintCategory.DEPRECATION);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Tue Jun 04 14:17:50 2013 -0700
@@ -32,6 +32,7 @@
import javax.tools.JavaFileObject;
import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.comp.Annotate;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Env;
@@ -74,35 +75,6 @@
*/
public long flags() { return flags_field; }
- /** The attributes of this symbol are contained in this
- * Annotations. The Annotations instance is NOT immutable.
- */
- public final Annotations annotations = new Annotations(this);
-
- /** An accessor method for the attributes of this symbol.
- * Attributes of class symbols should be accessed through the accessor
- * method to make sure that the class symbol is loaded.
- */
- public List<Attribute.Compound> getRawAttributes() {
- return annotations.getDeclarationAttributes();
- }
-
- /** An accessor method for the type attributes of this symbol.
- * Attributes of class symbols should be accessed through the accessor
- * method to make sure that the class symbol is loaded.
- */
- public List<Attribute.TypeCompound> getRawTypeAttributes() {
- return annotations.getTypeAttributes();
- }
-
- /** Fetch a particular annotation from a symbol. */
- public Attribute.Compound attribute(Symbol anno) {
- for (Attribute.Compound a : getRawAttributes()) {
- if (a.type.tsym == anno) return a;
- }
- return null;
- }
-
/** The name of this symbol in Utf8 representation.
*/
public Name name;
@@ -123,6 +95,146 @@
*/
public Type erasure_field;
+ // <editor-fold defaultstate="collapsed" desc="annotations">
+
+ /** The attributes of this symbol are contained in this
+ * Annotations. The Annotations instance is NOT immutable.
+ */
+ protected Annotations annotations;
+
+ /** An accessor method for the attributes of this symbol.
+ * Attributes of class symbols should be accessed through the accessor
+ * method to make sure that the class symbol is loaded.
+ */
+ public List<Attribute.Compound> getRawAttributes() {
+ return (annotations == null)
+ ? List.<Attribute.Compound>nil()
+ : annotations.getDeclarationAttributes();
+ }
+
+ /** An accessor method for the type attributes of this symbol.
+ * Attributes of class symbols should be accessed through the accessor
+ * method to make sure that the class symbol is loaded.
+ */
+ public List<Attribute.TypeCompound> getRawTypeAttributes() {
+ return (annotations == null)
+ ? List.<Attribute.TypeCompound>nil()
+ : annotations.getTypeAttributes();
+ }
+
+ /** Fetch a particular annotation from a symbol. */
+ public Attribute.Compound attribute(Symbol anno) {
+ for (Attribute.Compound a : getRawAttributes()) {
+ if (a.type.tsym == anno) return a;
+ }
+ return null;
+ }
+
+ public boolean annotationsPendingCompletion() {
+ return annotations == null ? false : annotations.pendingCompletion();
+ }
+
+ public void appendAttributes(List<Attribute.Compound> l) {
+ if (l.nonEmpty()) {
+ initedAnnos().append(l);
+ }
+ }
+
+ public void appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) {
+ if (l.nonEmpty()) {
+ initedAnnos().appendClassInitTypeAttributes(l);
+ }
+ }
+
+ public void appendInitTypeAttributes(List<Attribute.TypeCompound> l) {
+ if (l.nonEmpty()) {
+ initedAnnos().appendInitTypeAttributes(l);
+ }
+ }
+
+ public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) {
+ initedAnnos().appendTypeAttributesWithCompletion(ctx);
+ }
+
+ public void appendUniqueTypeAttributes(List<Attribute.TypeCompound> l) {
+ if (l.nonEmpty()) {
+ initedAnnos().appendUniqueTypes(l);
+ }
+ }
+
+ public List<Attribute.TypeCompound> getClassInitTypeAttributes() {
+ return (annotations == null)
+ ? List.<Attribute.TypeCompound>nil()
+ : annotations.getClassInitTypeAttributes();
+ }
+
+ public List<Attribute.TypeCompound> getInitTypeAttributes() {
+ return (annotations == null)
+ ? List.<Attribute.TypeCompound>nil()
+ : annotations.getInitTypeAttributes();
+ }
+
+ public List<Attribute.Compound> getDeclarationAttributes() {
+ return (annotations == null)
+ ? List.<Attribute.Compound>nil()
+ : annotations.getDeclarationAttributes();
+ }
+
+ public boolean hasAnnotations() {
+ return (annotations != null && !annotations.isEmpty());
+ }
+
+ public boolean hasTypeAnnotations() {
+ return (annotations != null && !annotations.isTypesEmpty());
+ }
+
+ public void prependAttributes(List<Attribute.Compound> l) {
+ if (l.nonEmpty()) {
+ initedAnnos().prepend(l);
+ }
+ }
+
+ public void resetAnnotations() {
+ initedAnnos().reset();
+ }
+
+ public void setAttributes(Symbol other) {
+ if (annotations != null || other.annotations != null) {
+ initedAnnos().setAttributes(other.annotations);
+ }
+ }
+
+ public void setDeclarationAttributes(List<Attribute.Compound> a) {
+ if (annotations != null || a.nonEmpty()) {
+ initedAnnos().setDeclarationAttributes(a);
+ }
+ }
+
+ public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) {
+ initedAnnos().setDeclarationAttributesWithCompletion(ctx);
+ }
+
+ public void setTypeAttributes(List<Attribute.TypeCompound> a) {
+ if (annotations != null || a.nonEmpty()) {
+ if (annotations == null)
+ annotations = new Annotations(this);
+ annotations.setTypeAttributes(a);
+ }
+ }
+
+ private Annotations initedAnnos() {
+ if (annotations == null)
+ annotations = new Annotations(this);
+ return annotations;
+ }
+
+ /** This method is intended for debugging only. */
+ public Annotations getAnnotations() {
+ return annotations;
+ }
+
+ // </editor-fold>
+
/** Construct a symbol with given kind, flags, name, type and owner.
*/
public Symbol(int kind, long flags, Name name, Type type, Symbol owner) {
@@ -207,6 +319,10 @@
}
}
+ public boolean isDeprecated() {
+ return (flags_field & DEPRECATED) != 0;
+ }
+
public boolean isStatic() {
return
(flags() & STATIC) != 0 ||
@@ -726,8 +842,9 @@
}
private void mergeAttributes() {
- if (annotations.isEmpty() &&
- !package_info.annotations.isEmpty()) {
+ if (annotations == null &&
+ package_info.annotations != null) {
+ annotations = new Annotations(this);
annotations.setAttributes(package_info.annotations);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Jun 04 14:17:50 2013 -0700
@@ -271,8 +271,8 @@
}
}
- sym.annotations.reset();
- sym.annotations.setDeclarationAttributes(declAnnos.toList());
+ sym.resetAnnotations();
+ sym.setDeclarationAttributes(declAnnos.toList());
if (typeAnnos.isEmpty()) {
return;
@@ -284,7 +284,7 @@
// When type is null, put the type annotations to the symbol.
// This is used for constructor return annotations, for which
// no appropriate type exists.
- sym.annotations.appendUniqueTypes(typeAnnotations);
+ sym.appendUniqueTypeAttributes(typeAnnotations);
return;
}
@@ -318,7 +318,7 @@
sym.type = type;
}
- sym.annotations.appendUniqueTypes(typeAnnotations);
+ sym.appendUniqueTypeAttributes(typeAnnotations);
if (sym.getKind() == ElementKind.PARAMETER ||
sym.getKind() == ElementKind.LOCAL_VARIABLE ||
@@ -326,7 +326,7 @@
sym.getKind() == ElementKind.EXCEPTION_PARAMETER) {
// Make sure all type annotations from the symbol are also
// on the owner.
- sym.owner.annotations.appendUniqueTypes(sym.getRawTypeAttributes());
+ sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes());
}
}
@@ -855,7 +855,7 @@
Assert.error("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind());
}
if (v.getKind() != ElementKind.FIELD) {
- v.owner.annotations.appendUniqueTypes(v.getRawTypeAttributes());
+ v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes());
}
return;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jun 04 14:17:50 2013 -0700
@@ -757,11 +757,10 @@
// env.info.enclVar.attributes_field might not yet have been evaluated, and so might be
// null. In that case, calling augment will throw an NPE. To avoid this, for now we
// revert to the jdk 6 behavior and ignore the (unevaluated) attributes.
- if (env.info.enclVar.annotations.pendingCompletion()) {
+ if (env.info.enclVar.annotationsPendingCompletion()) {
env.info.lint = lintEnv.info.lint;
} else {
- env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.annotations,
- env.info.enclVar.flags());
+ env.info.lint = lintEnv.info.lint.augment(env.info.enclVar);
}
Lint prevLint = chk.setLint(env.info.lint);
@@ -881,7 +880,7 @@
MethodSymbol m = tree.sym;
boolean isDefaultMethod = (m.flags() & DEFAULT) != 0;
- Lint lint = env.info.lint.augment(m.annotations, m.flags());
+ Lint lint = env.info.lint.augment(m);
Lint prevLint = chk.setLint(lint);
MethodSymbol prevMethod = chk.setMethod(m);
try {
@@ -1052,7 +1051,7 @@
}
VarSymbol v = tree.sym;
- Lint lint = env.info.lint.augment(v.annotations, v.flags());
+ Lint lint = env.info.lint.augment(v);
Lint prevLint = chk.setLint(lint);
// Check that the variable's declared type is well-formed.
@@ -1121,9 +1120,9 @@
ClassSymbol cs = (ClassSymbol)env.info.scope.owner;
List<Attribute.TypeCompound> tas = localEnv.info.scope.owner.getRawTypeAttributes();
if ((tree.flags & STATIC) != 0) {
- cs.annotations.appendClassInitTypeAttributes(tas);
+ cs.appendClassInitTypeAttributes(tas);
} else {
- cs.annotations.appendInitTypeAttributes(tas);
+ cs.appendInitTypeAttributes(tas);
}
}
@@ -4118,7 +4117,7 @@
lintEnv = lintEnv.next;
// Having found the enclosing lint value, we can initialize the lint value for this class
- env.info.lint = lintEnv.info.lint.augment(c.annotations, c.flags());
+ env.info.lint = lintEnv.info.lint.augment(c);
Lint prevLint = chk.setLint(env.info.lint);
JavaFileObject prev = log.useSource(c.sourcefile);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Tue Jun 04 14:17:50 2013 -0700
@@ -161,7 +161,7 @@
Env<AttrContext> lintEnv = localEnv;
while (lintEnv.info.lint == null)
lintEnv = lintEnv.next;
- localEnv.info.lint = lintEnv.info.lint.augment(sym.annotations, sym.flags());
+ localEnv.info.lint = lintEnv.info.lint.augment(sym);
return localEnv;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Jun 04 14:17:50 2013 -0700
@@ -434,7 +434,7 @@
Lint lintPrev = lint;
pendingExits = new ListBuffer<PendingExit>();
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
try {
// process all the static initializers
@@ -470,7 +470,7 @@
if (tree.body == null) return;
Lint lintPrev = lint;
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
Assert.check(pendingExits.isEmpty());
@@ -496,7 +496,7 @@
public void visitVarDef(JCVariableDecl tree) {
if (tree.init != null) {
Lint lintPrev = lint;
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
try{
scan(tree.init);
} finally {
@@ -836,7 +836,7 @@
}
classDef = tree;
thrown = List.nil();
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
try {
// process all the static initializers
@@ -916,7 +916,7 @@
List<Type> mthrown = tree.sym.type.getThrownTypes();
Lint lintPrev = lint;
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
Assert.check(pendingExits.isEmpty());
@@ -955,7 +955,7 @@
public void visitVarDef(JCVariableDecl tree) {
if (tree.init != null) {
Lint lintPrev = lint;
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
try{
scan(tree.init);
} finally {
@@ -1580,7 +1580,7 @@
firstadr = nextadr;
}
classDef = tree;
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
try {
// define all the static fields
@@ -1648,7 +1648,7 @@
int returnadrPrev = returnadr;
Lint lintPrev = lint;
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
Assert.check(pendingExits.isEmpty());
@@ -1700,7 +1700,7 @@
if (track && tree.sym.owner.kind == MTH) newVar(tree.sym);
if (tree.init != null) {
Lint lintPrev = lint;
- lint = lint.augment(tree.sym.annotations);
+ lint = lint.augment(tree.sym);
try{
scanExpr(tree.init);
if (track) letInit(tree.pos(), tree.sym);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Jun 04 14:17:50 2013 -0700
@@ -249,8 +249,8 @@
}
}
if (lambdaTypeAnnos.nonEmpty()) {
- owner.annotations.setTypeAttributes(ownerTypeAnnos.toList());
- sym.annotations.setTypeAttributes(lambdaTypeAnnos.toList());
+ owner.setTypeAttributes(ownerTypeAnnos.toList());
+ sym.setTypeAttributes(lambdaTypeAnnos.toList());
}
}
@@ -389,15 +389,15 @@
if (lambdaContext.getSymbolMap(PARAM).containsKey(tree.sym)) {
Symbol translatedSym = lambdaContext.getSymbolMap(PARAM).get(tree.sym);
result = make.Ident(translatedSym).setType(tree.type);
- translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes());
+ translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes());
} else if (lambdaContext.getSymbolMap(LOCAL_VAR).containsKey(tree.sym)) {
Symbol translatedSym = lambdaContext.getSymbolMap(LOCAL_VAR).get(tree.sym);
result = make.Ident(translatedSym).setType(tree.type);
- translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes());
+ translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes());
} else if (lambdaContext.getSymbolMap(TYPE_VAR).containsKey(tree.sym)) {
Symbol translatedSym = lambdaContext.getSymbolMap(TYPE_VAR).get(tree.sym);
result = make.Ident(translatedSym).setType(translatedSym.type);
- translatedSym.annotations.setTypeAttributes(tree.sym.getRawTypeAttributes());
+ translatedSym.setTypeAttributes(tree.sym.getRawTypeAttributes());
} else if (lambdaContext.getSymbolMap(CAPTURED_VAR).containsKey(tree.sym)) {
Symbol translatedSym = lambdaContext.getSymbolMap(CAPTURED_VAR).get(tree.sym);
result = make.Ident(translatedSym).setType(tree.type);
@@ -1715,8 +1715,8 @@
ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
}
if (ret != sym) {
- ret.annotations.setDeclarationAttributes(sym.getRawAttributes());
- ret.annotations.setTypeAttributes(sym.getRawTypeAttributes());
+ ret.setDeclarationAttributes(sym.getRawAttributes());
+ ret.setTypeAttributes(sym.getRawTypeAttributes());
}
return ret;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Jun 04 14:17:50 2013 -0700
@@ -2360,7 +2360,7 @@
null, List.<JCExpression>nil(), List.<JCTree>nil());
ClassSymbol c = tree.packge.package_info;
c.flags_field |= flags;
- c.annotations.setAttributes(tree.packge.annotations);
+ c.setAttributes(tree.packge);
ClassType ctype = (ClassType) c.type;
ctype.supertype_field = syms.objectType;
ctype.interfaces_field = List.nil();
@@ -2378,7 +2378,7 @@
return tree.packageAnnotations.nonEmpty();
case NONEMPTY:
for (Attribute.Compound a :
- tree.packge.annotations.getDeclarationAttributes()) {
+ tree.packge.getDeclarationAttributes()) {
Attribute.RetentionPolicy p = types.getRetention(a);
if (p != Attribute.RetentionPolicy.SOURCE)
return true;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Jun 04 14:17:50 2013 -0700
@@ -712,7 +712,7 @@
public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) {
Env<AttrContext> mEnv = methodEnv(tree, env);
- mEnv.info.lint = mEnv.info.lint.augment(tree.sym.annotations, tree.sym.flags());
+ mEnv.info.lint = mEnv.info.lint.augment(tree.sym);
for (List<JCTypeParameter> l = tree.typarams; l.nonEmpty(); l = l.tail)
mEnv.info.scope.enterIfAbsent(l.head.type.tsym);
for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail)
@@ -753,7 +753,7 @@
return;
}
if (s.kind != PCK) {
- s.annotations.reset(); // mark Annotations as incomplete for now
+ s.resetAnnotations(); // mark Annotations as incomplete for now
}
annotate.normal(new Annotate.Annotator() {
@Override
@@ -763,10 +763,10 @@
@Override
public void enterAnnotation() {
- Assert.check(s.kind == PCK || s.annotations.pendingCompletion());
+ Assert.check(s.kind == PCK || s.annotationsPendingCompletion());
JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
try {
- if (!s.annotations.isEmpty() &&
+ if (s.hasAnnotations() &&
annotations.nonEmpty())
log.error(annotations.head.pos,
"already.annotated",
@@ -832,7 +832,7 @@
}
}
- s.annotations.setDeclarationAttributesWithCompletion(
+ s.setDeclarationAttributesWithCompletion(
annotate.new AnnotateRepeatedContext<Attribute.Compound>(env, annotated, pos, log, false));
}
@@ -1107,7 +1107,7 @@
}
if (s != null) {
- s.annotations.appendTypeAttributesWithCompletion(
+ s.appendTypeAttributesWithCompletion(
annotate.new AnnotateRepeatedContext<Attribute.TypeCompound>(env, annotated, pos, log, true));
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Jun 04 14:17:50 2013 -0700
@@ -262,9 +262,7 @@
* be applied to method addOverrideBridgesIfNeeded
*/
bridge.params = createBridgeParams(impl, bridge, bridgeType);
- if (impl.annotations != null) {
- bridge.annotations.setAttributes(impl.annotations);
- }
+ bridge.setAttributes(impl);
if (!hypothetical) {
JCMethodDecl md = make.MethodDef(bridge, null);
@@ -311,9 +309,7 @@
while (implParams.nonEmpty() && argTypes.nonEmpty()) {
VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC,
implParams.head.name, argTypes.head, bridge);
- if (implParams.head.annotations != null) {
- param.annotations.setAttributes(implParams.head.annotations);
- }
+ param.setAttributes(implParams.head);
bridgeParams = bridgeParams.append(param);
implParams = implParams.tail;
argTypes = argTypes.tail;
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Jun 04 14:17:50 2013 -0700
@@ -1896,12 +1896,11 @@
JavaFileObject previousClassFile = currentClassFile;
try {
currentClassFile = classFile;
- Annotations annotations = sym.annotations;
List<Attribute.Compound> newList = deproxyCompoundList(l);
- if (annotations.pendingCompletion()) {
- annotations.setDeclarationAttributes(newList);
+ if (sym.annotationsPendingCompletion()) {
+ sym.setDeclarationAttributes(newList);
} else {
- annotations.append(newList);
+ sym.appendAttributes(newList);
}
} finally {
currentClassFile = previousClassFile;
@@ -1935,7 +1934,7 @@
try {
currentClassFile = classFile;
List<Attribute.TypeCompound> newList = deproxyTypeCompoundList(proxies);
- sym.annotations.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes()));
+ sym.setTypeAttributes(newList.prependList(sym.getRawTypeAttributes()));
} finally {
currentClassFile = previousClassFile;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Jun 04 14:17:50 2013 -0700
@@ -1960,8 +1960,7 @@
}
private void fillLocalVarPosition(LocalVar lv) {
- if (lv == null || lv.sym == null
- || lv.sym.annotations.isTypesEmpty())
+ if (lv == null || lv.sym == null || !lv.sym.hasTypeAnnotations())
return;
for (Attribute.TypeCompound ta : lv.sym.getRawTypeAttributes()) {
TypeAnnotationPosition p = ta.position;
@@ -1979,7 +1978,7 @@
for (int i = 0; i < varBufferSize; ++i) {
LocalVar lv = varBuffer[i];
if (lv == null || lv.sym == null
- || lv.sym.annotations.isTypesEmpty()
+ || !lv.sym.hasTypeAnnotations()
|| !lv.sym.isExceptionParameter())
continue;
@@ -2028,7 +2027,7 @@
// 2) it is an exception type and it contains type annotations
if (!varDebugInfo &&
(!var.sym.isExceptionParameter() ||
- var.sym.annotations.isTypesEmpty())) return;
+ var.sym.hasTypeAnnotations())) return;
if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return;
if (varBuffer == null)
varBuffer = new LocalVar[20];
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Jun 04 14:17:50 2013 -0700
@@ -518,7 +518,7 @@
// Insert any instance initializers into all constructors.
if (initCode.length() != 0) {
List<JCStatement> inits = initCode.toList();
- initTAs.addAll(c.annotations.getInitTypeAttributes());
+ initTAs.addAll(c.getInitTypeAttributes());
List<Attribute.TypeCompound> initTAlist = initTAs.toList();
for (JCTree t : methodDefs) {
normalizeMethod((JCMethodDecl)t, inits, initTAlist);
@@ -541,9 +541,9 @@
methodDefs.append(make.MethodDef(clinit, block));
if (!clinitTAs.isEmpty())
- clinit.annotations.appendUniqueTypes(clinitTAs.toList());
- if (!c.annotations.getClassInitTypeAttributes().isEmpty())
- clinit.annotations.appendUniqueTypes(c.annotations.getClassInitTypeAttributes());
+ clinit.appendUniqueTypeAttributes(clinitTAs.toList());
+ if (!c.getClassInitTypeAttributes().isEmpty())
+ clinit.appendUniqueTypeAttributes(c.getClassInitTypeAttributes());
}
// Return all method definitions.
return methodDefs.toList();
@@ -560,7 +560,7 @@
nonfieldTAs.add(ta);
}
}
- sym.annotations.setTypeAttributes(fieldTAs.toList());
+ sym.setTypeAttributes(fieldTAs.toList());
return nonfieldTAs.toList();
}
@@ -618,7 +618,7 @@
if (md.body.endpos == Position.NOPOS)
md.body.endpos = TreeInfo.endPos(md.body.stats.last());
- md.sym.annotations.appendUniqueTypes(initTAs);
+ md.sym.appendUniqueTypeAttributes(initTAs);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java Tue Jun 04 14:17:50 2013 -0700
@@ -160,7 +160,7 @@
for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0)
return true;
- for (Attribute.Compound a: i.sym.annotations.getDeclarationAttributes()) {
+ for (Attribute.Compound a: i.sym.getDeclarationAttributes()) {
if (a.type.tsym == syms.nativeHeaderType.tsym)
return true;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Tue Jun 04 14:17:50 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -225,11 +225,11 @@
}
ClassSymbol cs = (ClassSymbol) sym;
if (addLegacyAnnotation) {
- cs.annotations.prepend(List.of(proprietaryAnno));
+ cs.prependAttributes(List.of(proprietaryAnno));
}
int p = profiles.getProfile(cs.fullname.toString().replace(".", "/"));
if (0 < p && p < profileAnnos.length)
- cs.annotations.prepend(List.of(profileAnnos[p]));
+ cs.prependAttributes(List.of(profileAnnos[p]));
writeClass(pool, cs, writer);
}
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Jun 04 14:17:50 2013 -0700
@@ -1131,6 +1131,14 @@
private static class TypeAnnotationFinder extends TreeScanner {
public boolean foundTypeAnno = false;
+
+ @Override
+ public void scan(JCTree tree) {
+ if (foundTypeAnno || tree == null)
+ return;
+ super.scan(tree);
+ }
+
public void visitAnnotation(JCAnnotation tree) {
foundTypeAnno = foundTypeAnno || tree.hasTag(TYPE_ANNOTATION);
}
--- a/langtools/test/tools/javac/lib/DPrinter.java Tue Jun 04 13:21:41 2013 +0100
+++ b/langtools/test/tools/javac/lib/DPrinter.java Tue Jun 04 14:17:50 2013 -0700
@@ -403,7 +403,7 @@
printType("type", sym.type, Details.SUMMARY);
printType("erasure", sym.erasure_field, Details.SUMMARY);
sym.accept(symVisitor, null);
- printAnnotations("annotations", sym.annotations, Details.SUMMARY);
+ printAnnotations("annotations", sym.getAnnotations(), Details.SUMMARY);
indent(-1);
}
}