src/share/classes/com/sun/tools/javac/code/Symbol.java

changeset 1313
873ddd9f4900
parent 1239
2827076dbf64
child 1336
26d93df3905a
equal deleted inserted replaced
1310:542c87b8ce7f 1313:873ddd9f4900
70 * Flags of class symbols should be accessed through the accessor 70 * Flags of class symbols should be accessed through the accessor
71 * method to make sure that the class symbol is loaded. 71 * method to make sure that the class symbol is loaded.
72 */ 72 */
73 public long flags() { return flags_field; } 73 public long flags() { return flags_field; }
74 74
75 /** The attributes of this symbol. 75 /** The attributes of this symbol are contained in this
76 */ 76 * Annotations. The Annotations instance is NOT immutable.
77 public List<Attribute.Compound> attributes_field; 77 */
78 public final Annotations annotations = new Annotations(this);
78 79
79 /** An accessor method for the attributes of this symbol. 80 /** An accessor method for the attributes of this symbol.
80 * Attributes of class symbols should be accessed through the accessor 81 * Attributes of class symbols should be accessed through the accessor
81 * method to make sure that the class symbol is loaded. 82 * method to make sure that the class symbol is loaded.
82 */ 83 */
83 public List<Attribute.Compound> getAnnotationMirrors() { 84 public List<Attribute.Compound> getAnnotationMirrors() {
84 return Assert.checkNonNull(attributes_field); 85 return Assert.checkNonNull(annotations.getAttributes());
85 } 86 }
86 87
87 /** Fetch a particular annotation from a symbol. */ 88 /** Fetch a particular annotation from a symbol. */
88 public Attribute.Compound attribute(Symbol anno) { 89 public Attribute.Compound attribute(Symbol anno) {
89 for (Attribute.Compound a : getAnnotationMirrors()) 90 for (Attribute.Compound a : getAnnotationMirrors()) {
90 if (a.type.tsym == anno) return a; 91 if (a.type.tsym == anno) return a;
92 }
91 return null; 93 return null;
92 } 94 }
93 95
94 /** The name of this symbol in Utf8 representation. 96 /** The name of this symbol in Utf8 representation.
95 */ 97 */
118 this.flags_field = flags; 120 this.flags_field = flags;
119 this.type = type; 121 this.type = type;
120 this.owner = owner; 122 this.owner = owner;
121 this.completer = null; 123 this.completer = null;
122 this.erasure_field = null; 124 this.erasure_field = null;
123 this.attributes_field = List.nil();
124 this.name = name; 125 this.name = name;
125 } 126 }
126 127
127 /** Clone this symbol with new owner. 128 /** Clone this symbol with new owner.
128 * Legal only for fields and methods. 129 * Legal only for fields and methods.
655 656
656 public List<Attribute.Compound> getAnnotationMirrors() { 657 public List<Attribute.Compound> getAnnotationMirrors() {
657 if (completer != null) complete(); 658 if (completer != null) complete();
658 if (package_info != null && package_info.completer != null) { 659 if (package_info != null && package_info.completer != null) {
659 package_info.complete(); 660 package_info.complete();
660 if (attributes_field.isEmpty()) 661 if (annotations.isEmpty()) {
661 attributes_field = package_info.attributes_field; 662 annotations.setAttributes(package_info.annotations);
662 } 663 }
663 return Assert.checkNonNull(attributes_field); 664 }
665 return Assert.checkNonNull(annotations.getAttributes());
664 } 666 }
665 667
666 /** A package "exists" if a type or package that exists has 668 /** A package "exists" if a type or package that exists has
667 * been seen within it. 669 * been seen within it.
668 */ 670 */
760 return members_field; 762 return members_field;
761 } 763 }
762 764
763 public List<Attribute.Compound> getAnnotationMirrors() { 765 public List<Attribute.Compound> getAnnotationMirrors() {
764 if (completer != null) complete(); 766 if (completer != null) complete();
765 return Assert.checkNonNull(attributes_field); 767 return Assert.checkNonNull(annotations.getAttributes());
766 } 768 }
767 769
768 public Type erasure(Types types) { 770 public Type erasure(Types types) {
769 if (erasure_field == null) 771 if (erasure_field == null)
770 erasure_field = new ClassType(types.erasure(type.getEnclosingType()), 772 erasure_field = new ClassType(types.erasure(type.getEnclosingType()),

mercurial