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

changeset 1755
ddb4a2bfcd82
parent 1521
71f35e4b93a5
equal deleted inserted replaced
1754:0384683c64be 1755:ddb4a2bfcd82
74 * This field should never be null 74 * This field should never be null
75 */ 75 */
76 private List<Attribute.Compound> attributes = DECL_NOT_STARTED; 76 private List<Attribute.Compound> attributes = DECL_NOT_STARTED;
77 77
78 /* 78 /*
79 * This field should never be null 79 * Type attributes for this symbol.
80 * This field should never be null.
80 */ 81 */
81 private List<Attribute.TypeCompound> type_attributes = List.<Attribute.TypeCompound>nil(); 82 private List<Attribute.TypeCompound> type_attributes = List.<Attribute.TypeCompound>nil();
83
84 /*
85 * Type attributes of initializers in this class.
86 * Unused if the current symbol is not a ClassSymbol.
87 */
88 private List<Attribute.TypeCompound> init_type_attributes = List.<Attribute.TypeCompound>nil();
89
90 /*
91 * Type attributes of class initializers in this class.
92 * Unused if the current symbol is not a ClassSymbol.
93 */
94 private List<Attribute.TypeCompound> clinit_type_attributes = List.<Attribute.TypeCompound>nil();
82 95
83 /* 96 /*
84 * The Symbol this Annotations instance belongs to 97 * The Symbol this Annotations instance belongs to
85 */ 98 */
86 private final Symbol sym; 99 private final Symbol sym;
93 return filterDeclSentinels(attributes); 106 return filterDeclSentinels(attributes);
94 } 107 }
95 108
96 public List<Attribute.TypeCompound> getTypeAttributes() { 109 public List<Attribute.TypeCompound> getTypeAttributes() {
97 return type_attributes; 110 return type_attributes;
111 }
112
113 public List<Attribute.TypeCompound> getInitTypeAttributes() {
114 return init_type_attributes;
115 }
116
117 public List<Attribute.TypeCompound> getClassInitTypeAttributes() {
118 return clinit_type_attributes;
98 } 119 }
99 120
100 public void setDeclarationAttributes(List<Attribute.Compound> a) { 121 public void setDeclarationAttributes(List<Attribute.Compound> a) {
101 Assert.check(pendingCompletion() || !isStarted()); 122 Assert.check(pendingCompletion() || !isStarted());
102 if (a == null) { 123 if (a == null) {
110 throw new NullPointerException(); 131 throw new NullPointerException();
111 } 132 }
112 type_attributes = a; 133 type_attributes = a;
113 } 134 }
114 135
136 public void setInitTypeAttributes(List<Attribute.TypeCompound> a) {
137 if (a == null) {
138 throw new NullPointerException();
139 }
140 init_type_attributes = a;
141 }
142
143 public void setClassInitTypeAttributes(List<Attribute.TypeCompound> a) {
144 if (a == null) {
145 throw new NullPointerException();
146 }
147 clinit_type_attributes = a;
148 }
149
115 public void setAttributes(Annotations other) { 150 public void setAttributes(Annotations other) {
116 if (other == null) { 151 if (other == null) {
117 throw new NullPointerException(); 152 throw new NullPointerException();
118 } 153 }
119 setDeclarationAttributes(other.getDeclarationAttributes()); 154 setDeclarationAttributes(other.getDeclarationAttributes());
120 setTypeAttributes(other.getTypeAttributes()); 155 setTypeAttributes(other.getTypeAttributes());
156 setInitTypeAttributes(other.getInitTypeAttributes());
157 setClassInitTypeAttributes(other.getClassInitTypeAttributes());
121 } 158 }
122 159
123 public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) { 160 public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) {
124 Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK)); 161 Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK));
125 this.setDeclarationAttributes(getAttributesForCompletion(ctx)); 162 this.setDeclarationAttributes(getAttributesForCompletion(ctx));
230 } 267 }
231 } 268 }
232 return this; 269 return this;
233 } 270 }
234 271
272 public Annotations appendInitTypeAttributes(List<Attribute.TypeCompound> l) {
273 if (l.isEmpty()) {
274 ; // no-op
275 } else if (init_type_attributes.isEmpty()) {
276 init_type_attributes = l;
277 } else {
278 init_type_attributes = init_type_attributes.appendList(l);
279 }
280 return this;
281 }
282
283 public Annotations appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) {
284 if (l.isEmpty()) {
285 ; // no-op
286 } else if (clinit_type_attributes.isEmpty()) {
287 clinit_type_attributes = l;
288 } else {
289 clinit_type_attributes = clinit_type_attributes.appendList(l);
290 }
291 return this;
292 }
293
235 public Annotations prepend(List<Attribute.Compound> l) { 294 public Annotations prepend(List<Attribute.Compound> l) {
236 attributes = filterDeclSentinels(attributes); 295 attributes = filterDeclSentinels(attributes);
237 296
238 if (l.isEmpty()) { 297 if (l.isEmpty()) {
239 ; // no-op 298 ; // no-op

mercurial