author | vromero |
Tue, 08 Jan 2013 13:47:57 +0000 | |
changeset 15040 | 99fd9483d3f0 |
parent 14547 | 86d8d242b0c4 |
child 15384 | 5a8d00abf076 |
permissions | -rw-r--r-- |
14547 | 1 |
/* |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
2 |
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
14547 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/** |
|
25 |
* @test |
|
26 |
* @bug 8003280 |
|
27 |
* @summary Add lambda tests |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
28 |
* perform automated checks in type inference in lambda expressions |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
29 |
* in different contexts |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
30 |
* @library ../../../lib |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
31 |
* @build JavacTestingAbstractThreadedTest |
14547 | 32 |
* @compile TypeInferenceComboTest.java |
33 |
* @run main/timeout=360 TypeInferenceComboTest |
|
34 |
*/ |
|
35 |
||
36 |
import java.net.URI; |
|
37 |
import java.util.Arrays; |
|
38 |
import javax.tools.Diagnostic; |
|
39 |
import javax.tools.JavaFileObject; |
|
40 |
import javax.tools.SimpleJavaFileObject; |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
41 |
import com.sun.source.util.JavacTask; |
14547 | 42 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
43 |
public class TypeInferenceComboTest |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
44 |
extends JavacTestingAbstractThreadedTest |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
45 |
implements Runnable { |
14547 | 46 |
enum Context { |
47 |
ASSIGNMENT("SAM#Type s = #LBody;"), |
|
48 |
METHOD_CALL("#GenericDeclKind void method1(SAM#Type s) { }\n" + |
|
49 |
"void method2() {\n" + |
|
50 |
" method1(#LBody);\n" + |
|
51 |
"}"), |
|
52 |
RETURN_OF_METHOD("SAM#Type method1() {\n" + |
|
53 |
" return #LBody;\n" + |
|
54 |
"}"), |
|
55 |
LAMBDA_RETURN_EXPRESSION("SAM2 s2 = () -> {return (SAM#Type)#LBody;};\n"), |
|
56 |
ARRAY_INITIALIZER("Object[] oarray = {\"a\", 1, (SAM#Type)#LBody};"); |
|
57 |
||
58 |
String context; |
|
59 |
||
60 |
Context(String context) { |
|
61 |
this.context = context; |
|
62 |
} |
|
63 |
||
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
64 |
String getContext(SamKind sk, TypeKind samTargetT, Keyword kw, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
65 |
TypeKind parameterT, TypeKind returnT, LambdaKind lk, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
66 |
ParameterKind pk, GenericDeclKind gdk, LambdaBody lb) { |
14547 | 67 |
String result = context; |
68 |
if (sk == SamKind.GENERIC) { |
|
69 |
if(this == Context.METHOD_CALL) { |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
70 |
result = result.replaceAll("#GenericDeclKind", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
71 |
gdk.getGenericDeclKind(samTargetT)); |
14547 | 72 |
if(gdk == GenericDeclKind.NON_GENERIC) |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
73 |
result = result.replaceAll("#Type", "<" + |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
74 |
samTargetT.typeStr + ">"); |
14547 | 75 |
else //#GenericDeclKind is <T> or <T extends xxx> |
76 |
result = result.replaceAll("#Type", "<T>"); |
|
77 |
} |
|
78 |
else { |
|
79 |
if(kw == Keyword.VOID) |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
80 |
result = result.replaceAll("#Type", "<" + |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
81 |
samTargetT.typeStr + ">"); |
14547 | 82 |
else |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
83 |
result = result.replaceAll("#Type", "<? " + kw.keyStr + |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
84 |
" " + samTargetT.typeStr + ">"); |
14547 | 85 |
} |
86 |
} |
|
87 |
else |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
88 |
result = result.replaceAll("#Type", ""). |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
89 |
replaceAll("#GenericDeclKind", ""); |
14547 | 90 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
91 |
return result.replaceAll("#LBody", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
92 |
lb.getLambdaBody(samTargetT, parameterT, returnT, lk, pk)); |
14547 | 93 |
} |
94 |
} |
|
95 |
||
96 |
enum SamKind { |
|
97 |
GENERIC("interface SAM<T> { #R m(#ARG); }"), |
|
98 |
NON_GENERIC("interface SAM { #R m(#ARG); }"); |
|
99 |
||
100 |
String sam_str; |
|
101 |
||
102 |
SamKind(String sam_str) { |
|
103 |
this.sam_str = sam_str; |
|
104 |
} |
|
105 |
||
106 |
String getSam(TypeKind parameterT, TypeKind returnT) { |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
107 |
return sam_str.replaceAll("#ARG", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
108 |
parameterT == TypeKind.VOID ? |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
109 |
"" : parameterT.typeStr + " arg") |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
110 |
.replaceAll("#R", returnT.typeStr); |
14547 | 111 |
} |
112 |
} |
|
113 |
||
114 |
enum TypeKind { |
|
115 |
VOID("void", ""), |
|
116 |
STRING("String", "\"hello\""), |
|
117 |
INTEGER("Integer", "1"), |
|
118 |
INT("int", "0"), |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
119 |
COMPARATOR("java.util.Comparator<String>", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
120 |
"(java.util.Comparator<String>)(a, b) -> a.length()-b.length()"), |
14547 | 121 |
SAM("SAM2", "null"), |
122 |
GENERIC("T", null); |
|
123 |
||
124 |
String typeStr; |
|
125 |
String valStr; |
|
126 |
||
127 |
TypeKind(String typeStr, String valStr) { |
|
128 |
this.typeStr = typeStr; |
|
129 |
this.valStr = valStr; |
|
130 |
} |
|
131 |
} |
|
132 |
||
133 |
enum LambdaKind { |
|
134 |
EXPRESSION("#VAL"), |
|
135 |
STATEMENT("{return #VAL;}"); |
|
136 |
||
137 |
String stmt; |
|
138 |
||
139 |
LambdaKind(String stmt) { |
|
140 |
this.stmt = stmt; |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
enum ParameterKind { |
|
145 |
EXPLICIT("#TYPE"), |
|
146 |
IMPLICIT(""); |
|
147 |
||
148 |
String paramTemplate; |
|
149 |
||
150 |
ParameterKind(String paramTemplate) { |
|
151 |
this.paramTemplate = paramTemplate; |
|
152 |
} |
|
153 |
} |
|
154 |
||
155 |
enum Keyword { |
|
156 |
SUPER("super"), |
|
157 |
EXTENDS("extends"), |
|
158 |
VOID(""); |
|
159 |
||
160 |
String keyStr; |
|
161 |
||
162 |
Keyword(String keyStr) { |
|
163 |
this.keyStr = keyStr; |
|
164 |
} |
|
165 |
} |
|
166 |
||
167 |
enum LambdaBody { |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
168 |
//no parameters, return type is one of the TypeKind |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
169 |
RETURN_VOID("() -> #RET"), |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
170 |
//has parameters, return type is one of the TypeKind |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
171 |
RETURN_ARG("(#PK arg) -> #RET"); |
14547 | 172 |
|
173 |
String bodyStr; |
|
174 |
||
175 |
LambdaBody(String bodyStr) { |
|
176 |
this.bodyStr = bodyStr; |
|
177 |
} |
|
178 |
||
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
179 |
String getLambdaBody(TypeKind samTargetT, TypeKind parameterT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
180 |
TypeKind returnT, LambdaKind lk, ParameterKind pk) { |
14547 | 181 |
String result = bodyStr.replaceAll("#PK", pk.paramTemplate); |
182 |
||
183 |
if(result.contains("#TYPE")) { |
|
184 |
if (parameterT == TypeKind.GENERIC && this != RETURN_VOID) |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
185 |
result = result.replaceAll("#TYPE", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
186 |
samTargetT == null? "": samTargetT.typeStr); |
14547 | 187 |
else |
188 |
result = result.replaceAll("#TYPE", parameterT.typeStr); |
|
189 |
} |
|
190 |
if (this == RETURN_ARG && parameterT == returnT) |
|
191 |
return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", "arg")); |
|
192 |
else { |
|
193 |
if(returnT != TypeKind.GENERIC) |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
194 |
return result.replaceAll("#RET", lk.stmt.replaceAll("#VAL", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
195 |
(returnT==TypeKind.VOID && |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
196 |
lk==LambdaKind.EXPRESSION) ? "{}" : returnT.valStr)); |
14547 | 197 |
else |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
198 |
return result.replaceAll("#RET", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
199 |
lk.stmt.replaceAll("#VAL", samTargetT.valStr)); |
14547 | 200 |
} |
201 |
} |
|
202 |
} |
|
203 |
||
204 |
enum GenericDeclKind { |
|
205 |
NON_GENERIC(""), |
|
206 |
GENERIC_NOBOUND("<T>"), |
|
207 |
GENERIC_BOUND("<T extends #ExtendedType>"); |
|
208 |
String typeStr; |
|
209 |
||
210 |
GenericDeclKind(String typeStr) { |
|
211 |
this.typeStr = typeStr; |
|
212 |
} |
|
213 |
||
214 |
String getGenericDeclKind(TypeKind et) { |
|
215 |
return typeStr.replaceAll("#ExtendedType", et==null? "":et.typeStr); |
|
216 |
} |
|
217 |
} |
|
218 |
||
219 |
boolean checkTypeInference() { |
|
220 |
if (parameterType == TypeKind.VOID) { |
|
221 |
if (lambdaBodyType != LambdaBody.RETURN_VOID) |
|
222 |
return false; |
|
223 |
} |
|
224 |
else if (lambdaBodyType != LambdaBody.RETURN_ARG) |
|
225 |
return false; |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
226 |
if ( genericDeclKind == GenericDeclKind.GENERIC_NOBOUND || |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
227 |
genericDeclKind == GenericDeclKind.GENERIC_BOUND ) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
228 |
if ( parameterType == TypeKind.GENERIC && |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
229 |
parameterKind == ParameterKind.IMPLICIT) //cyclic inference |
14547 | 230 |
return false; |
231 |
} |
|
232 |
return true; |
|
233 |
} |
|
234 |
||
235 |
String templateStr = "#C\n" + |
|
236 |
"interface SAM2 {\n" + |
|
237 |
" SAM m();\n" + |
|
238 |
"}\n"; |
|
239 |
SourceFile samSourceFile = new SourceFile("Sam.java", templateStr) { |
|
240 |
public String toString() { |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
241 |
return template.replaceAll("#C", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
242 |
samKind.getSam(parameterType, returnType)); |
14547 | 243 |
} |
244 |
}; |
|
245 |
||
246 |
SourceFile clientSourceFile = new SourceFile("Client.java", |
|
247 |
"class Client { \n" + |
|
248 |
" #Context\n" + |
|
249 |
"}") { |
|
250 |
public String toString() { |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
251 |
return template.replaceAll("#Context", |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
252 |
context.getContext(samKind, samTargetType, keyword, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
253 |
parameterType, returnType, lambdaKind, parameterKind, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
254 |
genericDeclKind, lambdaBodyType)); |
14547 | 255 |
} |
256 |
}; |
|
257 |
||
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
258 |
public void run() { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
259 |
outWriter.println("kk:"); |
14547 | 260 |
StringBuilder sb = new StringBuilder("SamKind:"); |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
261 |
sb.append(samKind).append(" SamTargetType:") |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
262 |
.append(samTargetType).append(" ParameterType:").append(parameterType) |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
263 |
.append(" ReturnType:").append(returnType).append(" Context:") |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
264 |
.append(context).append(" LambdaKind:").append(lambdaKind) |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
265 |
.append(" LambdaBodyType:").append(lambdaBodyType) |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
266 |
.append(" ParameterKind:").append(parameterKind).append(" Keyword:") |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
267 |
.append(keyword); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
268 |
outWriter.println(sb); |
14547 | 269 |
DiagnosticChecker dc = new DiagnosticChecker(); |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
270 |
JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), dc, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
271 |
null, null, Arrays.asList(samSourceFile, clientSourceFile)); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
272 |
try { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
273 |
ct.analyze(); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
274 |
} catch (Throwable t) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
275 |
processException(t); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
276 |
} |
14547 | 277 |
if (dc.errorFound == checkTypeInference()) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
278 |
throw new AssertionError(samSourceFile + "\n\n" + |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
279 |
clientSourceFile + "\n" + parameterType + " " + returnType); |
14547 | 280 |
} |
281 |
} |
|
282 |
||
283 |
abstract class SourceFile extends SimpleJavaFileObject { |
|
284 |
||
285 |
protected String template; |
|
286 |
||
287 |
public SourceFile(String filename, String template) { |
|
288 |
super(URI.create("myfo:/" + filename), JavaFileObject.Kind.SOURCE); |
|
289 |
this.template = template; |
|
290 |
} |
|
291 |
||
292 |
@Override |
|
293 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
|
294 |
return toString(); |
|
295 |
} |
|
296 |
||
297 |
public abstract String toString(); |
|
298 |
} |
|
299 |
||
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
300 |
static class DiagnosticChecker |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
301 |
implements javax.tools.DiagnosticListener<JavaFileObject> { |
14547 | 302 |
|
303 |
boolean errorFound = false; |
|
304 |
||
305 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
|
306 |
if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { |
|
307 |
errorFound = true; |
|
308 |
} |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
SamKind samKind; |
|
313 |
TypeKind samTargetType; |
|
314 |
TypeKind parameterType; |
|
315 |
TypeKind returnType; |
|
316 |
Context context; |
|
317 |
LambdaBody lambdaBodyType; |
|
318 |
LambdaKind lambdaKind; |
|
319 |
ParameterKind parameterKind; |
|
320 |
Keyword keyword; |
|
321 |
GenericDeclKind genericDeclKind; |
|
322 |
||
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
323 |
TypeInferenceComboTest(SamKind sk, TypeKind samTargetT, TypeKind parameterT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
324 |
TypeKind returnT, LambdaBody lb, Context c, LambdaKind lk, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
325 |
ParameterKind pk, Keyword kw, GenericDeclKind gdk) { |
14547 | 326 |
samKind = sk; |
327 |
samTargetType = samTargetT; |
|
328 |
parameterType = parameterT; |
|
329 |
returnType = returnT; |
|
330 |
context = c; |
|
331 |
lambdaKind = lk; |
|
332 |
parameterKind = pk; |
|
333 |
keyword = kw; |
|
334 |
lambdaBodyType = lb; |
|
335 |
genericDeclKind = gdk; |
|
336 |
} |
|
337 |
||
338 |
public static void main(String[] args) throws Exception { |
|
339 |
for(Context ct : Context.values()) { |
|
340 |
for (TypeKind returnT : TypeKind.values()) { |
|
341 |
for (TypeKind parameterT : TypeKind.values()) { |
|
342 |
for(LambdaBody lb : LambdaBody.values()) { |
|
343 |
for (ParameterKind parameterK : ParameterKind.values()) { |
|
344 |
for(LambdaKind lambdaK : LambdaKind.values()) { |
|
345 |
for (SamKind sk : SamKind.values()) { |
|
346 |
if (sk == SamKind.NON_GENERIC) { |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
347 |
generateNonGenericSAM(ct, returnT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
348 |
parameterT, lb, parameterK, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
349 |
lambdaK, sk); |
14547 | 350 |
} |
351 |
else if (sk == SamKind.GENERIC) { |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
352 |
generateGenericSAM(ct, returnT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
353 |
parameterT, lb, parameterK, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
354 |
lambdaK, sk); |
14547 | 355 |
} |
356 |
} |
|
357 |
} |
|
358 |
} |
|
359 |
} |
|
360 |
} |
|
361 |
} |
|
362 |
} |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
363 |
|
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
364 |
checkAfterExec(false); |
14547 | 365 |
} |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
366 |
|
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
367 |
static void generateNonGenericSAM(Context ct, TypeKind returnT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
368 |
TypeKind parameterT, LambdaBody lb, ParameterKind parameterK, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
369 |
LambdaKind lambdaK, SamKind sk) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
370 |
if(parameterT != TypeKind.GENERIC && returnT != TypeKind.GENERIC ) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
371 |
pool.execute(new TypeInferenceComboTest(sk, null, parameterT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
372 |
returnT, lb, ct, lambdaK, parameterK, null, null)); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
373 |
} |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
374 |
} |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
375 |
|
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
376 |
static void generateGenericSAM(Context ct, TypeKind returnT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
377 |
TypeKind parameterT, LambdaBody lb, ParameterKind parameterK, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
378 |
LambdaKind lambdaK, SamKind sk) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
379 |
for (Keyword kw : Keyword.values()) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
380 |
for (TypeKind samTargetT : TypeKind.values()) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
381 |
if(samTargetT != TypeKind.VOID && |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
382 |
samTargetT != TypeKind.INT && |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
383 |
samTargetT != TypeKind.GENERIC && |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
384 |
(parameterT == TypeKind.GENERIC || |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
385 |
returnT == TypeKind.GENERIC)) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
386 |
if(ct != Context.METHOD_CALL) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
387 |
pool.execute( |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
388 |
new TypeInferenceComboTest(sk, samTargetT, parameterT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
389 |
returnT, lb, ct, lambdaK, parameterK, kw, null)); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
390 |
} else {//Context.METHOD_CALL |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
391 |
for (GenericDeclKind gdk : |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
392 |
GenericDeclKind.values()) |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
393 |
pool.execute( |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
394 |
new TypeInferenceComboTest(sk, samTargetT, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
395 |
parameterT, returnT, lb, ct, lambdaK, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
396 |
parameterK, kw, gdk)); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
397 |
} |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
398 |
} |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
399 |
} |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
400 |
} |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
401 |
} |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
14547
diff
changeset
|
402 |
|
14547 | 403 |
} |