src/share/classes/com/sun/tools/javac/comp/Annotate.java

Print this page

        

*** 29,38 **** --- 29,40 ---- import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; + import static com.sun.tools.javac.tree.JCTree.Tag.*; + /** Enter annotations on symbols. Annotations accumulate in a queue, * which is processed at the top level of any set of recursive calls * requesting it be processed. * * <p><b>This is NOT part of any supported API.
*** 146,170 **** log.error(a.annotationType.pos(), "not.annotation.type", a.type.toString()); return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil()); } List<JCExpression> args = a.args; ! if (args.length() == 1 && args.head.getTag() != JCTree.ASSIGN) { // special case: elided "value=" assumed args.head = make.at(args.head.pos). Assign(make.Ident(names.value), args.head); } ListBuffer<Pair<MethodSymbol,Attribute>> buf = new ListBuffer<Pair<MethodSymbol,Attribute>>(); for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) { JCExpression t = tl.head; ! if (t.getTag() != JCTree.ASSIGN) { log.error(t.pos(), "annotation.value.must.be.name.value"); continue; } JCAssign assign = (JCAssign)t; ! if (assign.lhs.getTag() != JCTree.IDENT) { log.error(t.pos(), "annotation.value.must.be.name.value"); continue; } JCIdent left = (JCIdent)assign.lhs; Symbol method = rs.resolveQualifiedMethod(left.pos(), --- 148,172 ---- log.error(a.annotationType.pos(), "not.annotation.type", a.type.toString()); return new Attribute.Compound(a.type, List.<Pair<MethodSymbol,Attribute>>nil()); } List<JCExpression> args = a.args; ! if (args.length() == 1 && !args.head.hasTag(ASSIGN)) { // special case: elided "value=" assumed args.head = make.at(args.head.pos). Assign(make.Ident(names.value), args.head); } ListBuffer<Pair<MethodSymbol,Attribute>> buf = new ListBuffer<Pair<MethodSymbol,Attribute>>(); for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) { JCExpression t = tl.head; ! if (!t.hasTag(ASSIGN)) { log.error(t.pos(), "annotation.value.must.be.name.value"); continue; } JCAssign assign = (JCAssign)t; ! if (!assign.lhs.hasTag(IDENT)) { log.error(t.pos(), "annotation.value.must.be.name.value"); continue; } JCIdent left = (JCIdent)assign.lhs; Symbol method = rs.resolveQualifiedMethod(left.pos(),
*** 220,237 **** } return new Attribute.Class(types, (((JCFieldAccess) tree).selected).type); } if ((expected.tsym.flags() & Flags.ANNOTATION) != 0) { ! if (tree.getTag() != JCTree.ANNOTATION) { log.error(tree.pos(), "annotation.value.must.be.annotation"); expected = syms.errorType; } return enterAnnotation((JCAnnotation)tree, expected, env); } if (expected.tag == TypeTags.ARRAY) { // should really be isArray() ! if (tree.getTag() != JCTree.NEWARRAY) { tree = make.at(tree.pos). NewArray(null, List.<JCExpression>nil(), List.of(tree)); } JCNewArray na = (JCNewArray)tree; if (na.elemtype != null) { --- 222,239 ---- } return new Attribute.Class(types, (((JCFieldAccess) tree).selected).type); } if ((expected.tsym.flags() & Flags.ANNOTATION) != 0) { ! if (!tree.hasTag(ANNOTATION)) { log.error(tree.pos(), "annotation.value.must.be.annotation"); expected = syms.errorType; } return enterAnnotation((JCAnnotation)tree, expected, env); } if (expected.tag == TypeTags.ARRAY) { // should really be isArray() ! if (!tree.hasTag(NEWARRAY)) { tree = make.at(tree.pos). NewArray(null, List.<JCExpression>nil(), List.of(tree)); } JCNewArray na = (JCNewArray)tree; if (na.elemtype != null) {