70 |
71 |
71 sb.append(isStatic ? "static " : "") |
72 sb.append(isStatic ? "static " : "") |
72 .append(isPublic ? "public " : "") |
73 .append(isPublic ? "public " : "") |
73 .append(isEnum ? "enum " : isInterface ? "interface " : "class ") |
74 .append(isEnum ? "enum " : isInterface ? "interface " : "class ") |
74 .append(cl).append(" -- ") |
75 .append(cl).append(" -- ") |
75 .append(isMember? "member " : "" ) |
76 .append(isMember? "inner" : "" ) |
76 .append(isLocal? "local " : "" ) |
77 .append(isLocal? "inner" : "" ) |
77 .append(isAnon ? "anon" : "") |
78 .append(isAnon ? "anon" : "") |
78 .append("\n"); |
79 .append("\n"); |
79 |
80 |
80 for (Constructor c : clazz.getDeclaredConstructors()) { |
81 for (Constructor c : clazz.getDeclaredConstructors()) { |
81 testConstructor(c); |
82 testConstructor(c); |
82 } |
83 } |
83 |
84 |
84 for (Method m :clazz.getDeclaredMethods()) { |
85 for (Method m :clazz.getDeclaredMethods()) { |
85 |
|
86 testMethod(m); |
86 testMethod(m); |
87 } |
87 } |
88 } |
88 } |
89 |
89 |
90 void testConstructor(Constructor c) { |
90 void testConstructor(Constructor c) { |
114 int i = -1; |
114 int i = -1; |
115 String param = null; |
115 String param = null; |
116 for (Parameter p : c.getParameters()) { |
116 for (Parameter p : c.getParameters()) { |
117 i++; |
117 i++; |
118 String pname = p.getName(); |
118 String pname = p.getName(); |
|
119 int pmodifier = p.getModifiers(); |
|
120 isFinal = false; |
|
121 if (Modifier.isFinal(pmodifier)) { |
|
122 isFinal = true; |
|
123 pname = "final " + pname; |
|
124 } |
119 sb.append(sep).append(pname); |
125 sb.append(sep).append(pname); |
120 if (p.isImplicit()) sb.append("!"); |
126 if (p.isImplicit()) sb.append("/*implicit*/"); |
121 if (p.isSynthetic()) sb.append("!!"); |
127 if (p.isSynthetic()) sb.append("/*synthetic*/"); |
122 sep = ", "; |
128 sep = ", "; |
123 |
129 |
124 // Set expectations |
130 // Set expectations |
125 String expect = null; |
131 String expect = null; |
126 boolean allowImplicit = false; |
132 boolean allowImplicit = false; |
133 expect = "\\$enum\\$ordinal"; |
139 expect = "\\$enum\\$ordinal"; |
134 allowSynthetic = true; |
140 allowSynthetic = true; |
135 } |
141 } |
136 } else if (i == 0) { |
142 } else if (i == 0) { |
137 if (isAnon) { |
143 if (isAnon) { |
|
144 expect = "this\\$[0-9]+"; |
138 allowImplicit = true; |
145 allowImplicit = true; |
|
146 if (isFinal) |
|
147 expect = "final this\\$[0-9]+"; |
139 } else if (isLocal) { |
148 } else if (isLocal) { |
|
149 expect = "this\\$[0-9]+"; |
140 allowImplicit = true; |
150 allowImplicit = true; |
141 expect = "this\\$[0-n]*"; |
151 if (isFinal) |
|
152 expect = "final this\\$[0-9]+"; |
142 } else if ((isMember && !isStatic)) { |
153 } else if ((isMember && !isStatic)) { |
|
154 expect = "this\\$[0-9]+"; |
143 allowImplicit = true; |
155 allowImplicit = true; |
144 if (!isPublic) { |
156 if (!isPublic) { |
145 // some but not all non-public inner classes |
157 // some but not all non-public inner classes |
146 // have synthetic argument. For now we give |
158 // have synthetic argument. For now we give |
147 // the test a bit of slack and allow either. |
159 // the test a bit of slack and allow either. |
148 allowSynthetic = true; |
160 allowSynthetic = true; |
149 } |
161 } |
150 expect = "this\\$[0-n]*"; |
162 if (isFinal) |
|
163 expect = "final this\\$[0-9]+"; |
151 } |
164 } |
152 } |
165 } |
153 |
166 |
154 // Check expected flags |
167 // Check expected flags |
155 if (p.isSynthetic() && p.isImplicit()) { |
168 if (p.isSynthetic() && p.isImplicit()) { |
199 boolean fidelity = !isAnon; |
212 boolean fidelity = !isAnon; |
200 if (param != null && fidelity) { |
213 if (param != null && fidelity) { |
201 char ch = param.charAt(0); |
214 char ch = param.charAt(0); |
202 expect = (++ch) + param; |
215 expect = (++ch) + param; |
203 } |
216 } |
204 |
217 if (isFinal && expect != null) { |
|
218 expect = "final " + expect; |
|
219 } |
205 if (pname != null && fidelity) { |
220 if (pname != null && fidelity) { |
|
221 if (isFinal) { |
|
222 param = pname.substring(6); |
|
223 } else { |
206 param = pname; |
224 param = pname; |
207 } |
225 } |
208 |
226 } |
209 if (expect != null && !expect.equals(pname)) { |
227 if (expect != null && !expect.equals(pname)) { |
210 error(prefix + "param[" + i + "]='" + pname + |
228 error(prefix + "param[" + i + "]='" + pname + |
211 "' expected '" + expect + "'"); |
229 "' expected '" + expect + "'"); |
212 break; |
230 break; |
213 } |
231 } |
214 } |
232 } |
215 if (c.isSynthetic()) { |
233 if (c.isSynthetic()) { |
216 sb.append(")!!\n"); |
234 sb.append(")/*synthetic*/\n"); |
217 } else { |
235 } else { |
218 sb.append(")\n"); |
236 sb.append(")\n"); |
219 } |
237 } |
220 } |
238 } |
221 |
239 |
238 int i = -1; |
256 int i = -1; |
239 // For methods we expect all parameters to follow |
257 // For methods we expect all parameters to follow |
240 // the test-case design pattern, except synthetic methods. |
258 // the test-case design pattern, except synthetic methods. |
241 for (Parameter p : m.getParameters()) { |
259 for (Parameter p : m.getParameters()) { |
242 i++; |
260 i++; |
|
261 isFinal = false; |
|
262 int pmodifier = p.getModifiers(); |
243 if (param == null) { |
263 if (param == null) { |
244 param = p.getName(); |
264 param = p.getName(); |
|
265 if (Modifier.isFinal(pmodifier)) { |
|
266 isFinal = true; |
|
267 param = "final " + param; |
|
268 } |
245 sb.append(sep).append(param); |
269 sb.append(sep).append(param); |
246 } else { |
270 } else { |
247 char c = param.charAt(0); |
271 char c = param.charAt(0); |
248 String expect = m.isSynthetic() ? ("arg" + i) : ((++c) + param); |
272 String expect = m.isSynthetic() ? ("arg" + i) : ((++c) + param); |
249 param = p.getName(); |
273 param = p.getName(); |
|
274 if (Modifier.isFinal(pmodifier)) { |
|
275 isFinal = true; |
|
276 expect = "final " + expect; |
|
277 param = "final " + param; |
|
278 } |
250 sb.append(sep).append(param); |
279 sb.append(sep).append(param); |
251 if (!m.isBridge() && !expect.equals(param)) { |
280 if (!m.isBridge() && !expect.equals(param)) { |
252 error(prefix + "param[" + i + "]='" |
281 error(prefix + "param[" + i + "]='" |
253 + param + "' expected '" + expect + "'"); |
282 + param + "' expected '" + expect + "'"); |
254 break; |
283 break; |
255 } |
284 } |
256 } |
285 } |
|
286 if(isFinal) |
|
287 param = param.substring(6); |
|
288 if (p.isImplicit()) { |
|
289 sb.append("/*implicit*/"); |
|
290 } |
|
291 if (p.isSynthetic()) { |
|
292 sb.append("/*synthetic*/"); |
|
293 } |
257 sep = ", "; |
294 sep = ", "; |
258 } |
295 } |
259 if (m.isSynthetic()) { |
296 if (m.isSynthetic()) { |
260 sb.append(")!!\n"); |
297 sb.append(")/*synthetic*/\n"); |
261 } else { |
298 } else { |
262 sb.append(")\n"); |
299 sb.append(")\n"); |
263 } |
300 } |
264 } |
301 } |
265 } |
302 } |