author | mcimadamore |
Mon, 05 Dec 2016 19:00:56 +0000 | |
changeset 42416 | 1cfad0990b99 |
parent 39600 | 83ea7c12c164 |
child 42828 | cce89649f958 |
permissions | -rw-r--r-- |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
1 |
/* |
15356
cf312dc54c60
8006119: update javac to follow latest spec for repeatable annotations
jjg
parents:
14804
diff
changeset
|
2 |
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
4 |
* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
10 |
* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
15 |
* accompanied this code). |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
16 |
* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
20 |
* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
23 |
* questions. |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
24 |
*/ |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
25 |
|
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
26 |
package com.sun.tools.javac.code; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
27 |
|
14258 | 28 |
|
39600
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
29 |
import com.sun.tools.javac.code.Attribute.TypeCompound; |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
30 |
import com.sun.tools.javac.code.Kinds.Kind; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
31 |
import com.sun.tools.javac.util.Assert; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
32 |
import com.sun.tools.javac.util.List; |
39600
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
33 |
import com.sun.tools.javac.util.ListBuffer; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
34 |
|
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
35 |
/** |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
36 |
* Container for all annotations (attributes in javac) on a Symbol. |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
37 |
* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
38 |
* This class is explicitly mutable. Its contents will change when attributes |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
39 |
* are annotated onto the Symbol. However this class depends on the facts that |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
40 |
* List (in javac) is immutable. |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
41 |
* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
42 |
* An instance of this class can be in one of three states: |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
43 |
* |
15385 | 44 |
* NOT_STARTED indicates that the Symbol this instance belongs to has not been |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
45 |
* annotated (yet). Specifically if the declaration is not annotated this |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
46 |
* instance will never move past NOT_STARTED. You can never go back to |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
47 |
* NOT_STARTED. |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
48 |
* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
49 |
* IN_PROGRESS annotations have been found on the declaration. Will be processed |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
50 |
* later. You can reset to IN_PROGRESS. While IN_PROGRESS you can set the list |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
51 |
* of attributes (and this moves out of the IN_PROGRESS state). |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
52 |
* |
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
53 |
* "unnamed" this SymbolMetadata contains some attributes, possibly the final set. |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
54 |
* While in this state you can only prepend or append to the attributes not set |
15385 | 55 |
* it directly. You can also move back to the IN_PROGRESS state using reset(). |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
56 |
* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
57 |
* <p><b>This is NOT part of any supported API. If you write code that depends |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
58 |
* on this, you do so at your own risk. This code and its internal interfaces |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
59 |
* are subject to change or deletion without notice.</b> |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
60 |
*/ |
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
61 |
public class SymbolMetadata { |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
62 |
|
15385 | 63 |
private static final List<Attribute.Compound> DECL_NOT_STARTED = List.of(null); |
64 |
private static final List<Attribute.Compound> DECL_IN_PROGRESS = List.of(null); |
|
65 |
||
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
66 |
/* |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
67 |
* This field should never be null |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
68 |
*/ |
15385 | 69 |
private List<Attribute.Compound> attributes = DECL_NOT_STARTED; |
70 |
||
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
71 |
/* |
17578 | 72 |
* Type attributes for this symbol. |
73 |
* This field should never be null. |
|
15385 | 74 |
*/ |
75 |
private List<Attribute.TypeCompound> type_attributes = List.<Attribute.TypeCompound>nil(); |
|
76 |
||
77 |
/* |
|
17578 | 78 |
* Type attributes of initializers in this class. |
79 |
* Unused if the current symbol is not a ClassSymbol. |
|
80 |
*/ |
|
81 |
private List<Attribute.TypeCompound> init_type_attributes = List.<Attribute.TypeCompound>nil(); |
|
82 |
||
83 |
/* |
|
84 |
* Type attributes of class initializers in this class. |
|
85 |
* Unused if the current symbol is not a ClassSymbol. |
|
86 |
*/ |
|
87 |
private List<Attribute.TypeCompound> clinit_type_attributes = List.<Attribute.TypeCompound>nil(); |
|
88 |
||
89 |
/* |
|
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
90 |
* The Symbol this SymbolMetadata instance belongs to |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
91 |
*/ |
14804
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14258
diff
changeset
|
92 |
private final Symbol sym; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
93 |
|
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
94 |
public SymbolMetadata(Symbol sym) { |
14804
f93a8d60b9a4
8001114: Container annotation is not checked for semantic correctness
jfranck
parents:
14258
diff
changeset
|
95 |
this.sym = sym; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
96 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
97 |
|
15385 | 98 |
public List<Attribute.Compound> getDeclarationAttributes() { |
99 |
return filterDeclSentinels(attributes); |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
100 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
101 |
|
15385 | 102 |
public List<Attribute.TypeCompound> getTypeAttributes() { |
103 |
return type_attributes; |
|
104 |
} |
|
105 |
||
17578 | 106 |
public List<Attribute.TypeCompound> getInitTypeAttributes() { |
107 |
return init_type_attributes; |
|
108 |
} |
|
109 |
||
110 |
public List<Attribute.TypeCompound> getClassInitTypeAttributes() { |
|
111 |
return clinit_type_attributes; |
|
112 |
} |
|
113 |
||
15385 | 114 |
public void setDeclarationAttributes(List<Attribute.Compound> a) { |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
115 |
Assert.check(pendingCompletion() || !isStarted()); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
116 |
if (a == null) { |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
117 |
throw new NullPointerException(); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
118 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
119 |
attributes = a; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
120 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
121 |
|
15385 | 122 |
public void setTypeAttributes(List<Attribute.TypeCompound> a) { |
123 |
if (a == null) { |
|
124 |
throw new NullPointerException(); |
|
125 |
} |
|
126 |
type_attributes = a; |
|
127 |
} |
|
128 |
||
17578 | 129 |
public void setInitTypeAttributes(List<Attribute.TypeCompound> a) { |
130 |
if (a == null) { |
|
131 |
throw new NullPointerException(); |
|
132 |
} |
|
133 |
init_type_attributes = a; |
|
134 |
} |
|
135 |
||
136 |
public void setClassInitTypeAttributes(List<Attribute.TypeCompound> a) { |
|
137 |
if (a == null) { |
|
138 |
throw new NullPointerException(); |
|
139 |
} |
|
140 |
clinit_type_attributes = a; |
|
141 |
} |
|
142 |
||
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
143 |
public void setAttributes(SymbolMetadata other) { |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
144 |
if (other == null) { |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
145 |
throw new NullPointerException(); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
146 |
} |
15385 | 147 |
setDeclarationAttributes(other.getDeclarationAttributes()); |
39600
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
148 |
if ((sym.flags() & Flags.BRIDGE) != 0) { |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
149 |
Assert.check(other.sym.kind == Kind.MTH); |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
150 |
ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>(); |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
151 |
for (TypeCompound tc : other.getTypeAttributes()) { |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
152 |
// Carry over only contractual type annotations: i.e nothing interior to method body. |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
153 |
if (!tc.position.type.isLocal()) |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
154 |
typeAttributes.append(tc); |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
155 |
} |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
156 |
setTypeAttributes(typeAttributes.toList()); |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
157 |
} else { |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
158 |
setTypeAttributes(other.getTypeAttributes()); |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
159 |
} |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
160 |
if (sym.kind == Kind.TYP) { |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
161 |
setInitTypeAttributes(other.getInitTypeAttributes()); |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
162 |
setClassInitTypeAttributes(other.getClassInitTypeAttributes()); |
83ea7c12c164
8160928: javac incorrectly copies over interior type annotations to bridge method
sadayapalam
parents:
25874
diff
changeset
|
163 |
} |
15385 | 164 |
} |
165 |
||
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
166 |
public SymbolMetadata reset() { |
15385 | 167 |
attributes = DECL_IN_PROGRESS; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
168 |
return this; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
169 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
170 |
|
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
171 |
public boolean isEmpty() { |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
172 |
return !isStarted() |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
173 |
|| pendingCompletion() |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
174 |
|| attributes.isEmpty(); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
175 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
176 |
|
15385 | 177 |
public boolean isTypesEmpty() { |
178 |
return type_attributes.isEmpty(); |
|
179 |
} |
|
180 |
||
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
181 |
public boolean pendingCompletion() { |
15385 | 182 |
return attributes == DECL_IN_PROGRESS; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
183 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
184 |
|
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
185 |
public SymbolMetadata append(List<Attribute.Compound> l) { |
15385 | 186 |
attributes = filterDeclSentinels(attributes); |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
187 |
|
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
188 |
if (l.isEmpty()) { |
22163 | 189 |
// no-op |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
190 |
} else if (attributes.isEmpty()) { |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
191 |
attributes = l; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
192 |
} else { |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
193 |
attributes = attributes.appendList(l); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
194 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
195 |
return this; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
196 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
197 |
|
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
198 |
public SymbolMetadata appendUniqueTypes(List<Attribute.TypeCompound> l) { |
15385 | 199 |
if (l.isEmpty()) { |
22163 | 200 |
// no-op |
15385 | 201 |
} else if (type_attributes.isEmpty()) { |
202 |
type_attributes = l; |
|
203 |
} else { |
|
204 |
// TODO: in case we expect a large number of annotations, this |
|
205 |
// might be inefficient. |
|
206 |
for (Attribute.TypeCompound tc : l) { |
|
207 |
if (!type_attributes.contains(tc)) |
|
208 |
type_attributes = type_attributes.append(tc); |
|
209 |
} |
|
210 |
} |
|
211 |
return this; |
|
212 |
} |
|
213 |
||
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
214 |
public SymbolMetadata appendInitTypeAttributes(List<Attribute.TypeCompound> l) { |
17578 | 215 |
if (l.isEmpty()) { |
22163 | 216 |
// no-op |
17578 | 217 |
} else if (init_type_attributes.isEmpty()) { |
218 |
init_type_attributes = l; |
|
219 |
} else { |
|
220 |
init_type_attributes = init_type_attributes.appendList(l); |
|
221 |
} |
|
222 |
return this; |
|
223 |
} |
|
224 |
||
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
225 |
public SymbolMetadata appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) { |
17578 | 226 |
if (l.isEmpty()) { |
22163 | 227 |
// no-op |
17578 | 228 |
} else if (clinit_type_attributes.isEmpty()) { |
229 |
clinit_type_attributes = l; |
|
230 |
} else { |
|
231 |
clinit_type_attributes = clinit_type_attributes.appendList(l); |
|
232 |
} |
|
233 |
return this; |
|
234 |
} |
|
235 |
||
19928
adce50c2b76c
8022260: Rename javac.code.Annotations to javac.code.SymbolMetadata
jfranck
parents:
17578
diff
changeset
|
236 |
public SymbolMetadata prepend(List<Attribute.Compound> l) { |
15385 | 237 |
attributes = filterDeclSentinels(attributes); |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
238 |
|
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
239 |
if (l.isEmpty()) { |
22163 | 240 |
// no-op |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
241 |
} else if (attributes.isEmpty()) { |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
242 |
attributes = l; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
243 |
} else { |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
244 |
attributes = attributes.prependList(l); |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
245 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
246 |
return this; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
247 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
248 |
|
15385 | 249 |
private List<Attribute.Compound> filterDeclSentinels(List<Attribute.Compound> a) { |
250 |
return (a == DECL_IN_PROGRESS || a == DECL_NOT_STARTED) |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
251 |
? List.<Attribute.Compound>nil() |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
252 |
: a; |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
253 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
254 |
|
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
255 |
private boolean isStarted() { |
15385 | 256 |
return attributes != DECL_NOT_STARTED; |
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
257 |
} |
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
diff
changeset
|
258 |
} |