1.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Mon Jan 21 01:27:42 2013 -0500 1.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Mon Feb 04 18:08:53 2013 -0500 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -169,10 +169,26 @@ 1.11 List<JCExpression> thrown, 1.12 JCBlock body, 1.13 JCExpression defaultValue) { 1.14 + return MethodDef( 1.15 + mods, name, restype, typarams, null, params, 1.16 + thrown, body, defaultValue); 1.17 + } 1.18 + 1.19 + public JCMethodDecl MethodDef(JCModifiers mods, 1.20 + Name name, 1.21 + JCExpression restype, 1.22 + List<JCTypeParameter> typarams, 1.23 + JCVariableDecl recvparam, 1.24 + List<JCVariableDecl> params, 1.25 + List<JCExpression> thrown, 1.26 + JCBlock body, 1.27 + JCExpression defaultValue) 1.28 + { 1.29 JCMethodDecl tree = new JCMethodDecl(mods, 1.30 name, 1.31 restype, 1.32 typarams, 1.33 + recvparam, 1.34 params, 1.35 thrown, 1.36 body, 1.37 @@ -463,7 +479,11 @@ 1.38 } 1.39 1.40 public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds) { 1.41 - JCTypeParameter tree = new JCTypeParameter(name, bounds); 1.42 + return TypeParameter(name, bounds, List.<JCAnnotation>nil()); 1.43 + } 1.44 + 1.45 + public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annos) { 1.46 + JCTypeParameter tree = new JCTypeParameter(name, bounds, annos); 1.47 tree.pos = pos; 1.48 return tree; 1.49 } 1.50 @@ -481,7 +501,13 @@ 1.51 } 1.52 1.53 public JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args) { 1.54 - JCAnnotation tree = new JCAnnotation(annotationType, args); 1.55 + JCAnnotation tree = new JCAnnotation(Tag.ANNOTATION, annotationType, args); 1.56 + tree.pos = pos; 1.57 + return tree; 1.58 + } 1.59 + 1.60 + public JCAnnotation TypeAnnotation(JCTree annotationType, List<JCExpression> args) { 1.61 + JCAnnotation tree = new JCAnnotation(Tag.TYPE_ANNOTATION, annotationType, args); 1.62 tree.pos = pos; 1.63 return tree; 1.64 } 1.65 @@ -497,6 +523,12 @@ 1.66 return Modifiers(flags, List.<JCAnnotation>nil()); 1.67 } 1.68 1.69 + public JCAnnotatedType AnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) { 1.70 + JCAnnotatedType tree = new JCAnnotatedType(annotations, underlyingType); 1.71 + tree.pos = pos; 1.72 + return tree; 1.73 + } 1.74 + 1.75 public JCErroneous Erroneous() { 1.76 return Erroneous(List.<JCTree>nil()); 1.77 } 1.78 @@ -755,7 +787,11 @@ 1.79 result = Erroneous(); 1.80 } 1.81 public void visitCompound(Attribute.Compound compound) { 1.82 - result = visitCompoundInternal(compound); 1.83 + if (compound instanceof Attribute.TypeCompound) { 1.84 + result = visitTypeCompoundInternal((Attribute.TypeCompound) compound); 1.85 + } else { 1.86 + result = visitCompoundInternal(compound); 1.87 + } 1.88 } 1.89 public JCAnnotation visitCompoundInternal(Attribute.Compound compound) { 1.90 ListBuffer<JCExpression> args = new ListBuffer<JCExpression>(); 1.91 @@ -766,6 +802,15 @@ 1.92 } 1.93 return Annotation(Type(compound.type), args.toList()); 1.94 } 1.95 + public JCAnnotation visitTypeCompoundInternal(Attribute.TypeCompound compound) { 1.96 + ListBuffer<JCExpression> args = new ListBuffer<JCExpression>(); 1.97 + for (List<Pair<Symbol.MethodSymbol,Attribute>> values = compound.values; values.nonEmpty(); values=values.tail) { 1.98 + Pair<MethodSymbol,Attribute> pair = values.head; 1.99 + JCExpression valueTree = translate(pair.snd); 1.100 + args.append(Assign(Ident(pair.fst), valueTree).setType(valueTree.type)); 1.101 + } 1.102 + return TypeAnnotation(Type(compound.type), args.toList()); 1.103 + } 1.104 public void visitArray(Attribute.Array array) { 1.105 ListBuffer<JCExpression> elems = new ListBuffer<JCExpression>(); 1.106 for (int i = 0; i < array.values.length; i++) 1.107 @@ -779,7 +824,11 @@ 1.108 JCAnnotation translate(Attribute.Compound a) { 1.109 return visitCompoundInternal(a); 1.110 } 1.111 + JCAnnotation translate(Attribute.TypeCompound a) { 1.112 + return visitTypeCompoundInternal(a); 1.113 + } 1.114 } 1.115 + 1.116 AnnotationBuilder annotationBuilder = new AnnotationBuilder(); 1.117 1.118 /** Create an annotation tree from an attribute. 1.119 @@ -788,6 +837,10 @@ 1.120 return annotationBuilder.translate((Attribute.Compound)a); 1.121 } 1.122 1.123 + public JCAnnotation TypeAnnotation(Attribute a) { 1.124 + return annotationBuilder.translate((Attribute.TypeCompound) a); 1.125 + } 1.126 + 1.127 /** Create a method definition from a method symbol and a method body. 1.128 */ 1.129 public JCMethodDecl MethodDef(MethodSymbol m, JCBlock body) { 1.130 @@ -804,6 +857,7 @@ 1.131 m.name, 1.132 Type(mtype.getReturnType()), 1.133 TypeParams(mtype.getTypeArguments()), 1.134 + null, // receiver type 1.135 Params(mtype.getParameterTypes(), m), 1.136 Types(mtype.getThrownTypes()), 1.137 body, 1.138 @@ -822,7 +876,6 @@ 1.139 */ 1.140 public List<JCTypeParameter> TypeParams(List<Type> typarams) { 1.141 ListBuffer<JCTypeParameter> tparams = new ListBuffer<JCTypeParameter>(); 1.142 - int i = 0; 1.143 for (List<Type> l = typarams; l.nonEmpty(); l = l.tail) 1.144 tparams.append(TypeParam(l.head.tsym.name, (TypeVar)l.head)); 1.145 return tparams.toList();