author | mchung |
Wed, 27 May 2015 13:25:18 -0700 | |
changeset 30846 | 2b3f379840f0 |
parent 30730 | d3ce7619db2c |
child 32454 | b0ac04e0fefe |
permissions | -rw-r--r-- |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
15384
diff
changeset
|
2 |
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
4 |
* |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
8 |
* |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
14 |
* |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
18 |
* |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
23 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
24 |
/* |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
15384
5a8d00abf076
8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents:
15040
diff
changeset
|
26 |
* @bug 7042566 8006694 |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
27 |
* @summary Unambiguous varargs method calls flagged as ambiguous |
15384
5a8d00abf076
8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents:
15040
diff
changeset
|
28 |
* temporarily workaround combo tests are causing time out in several platforms |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
29 |
* @library ../../lib |
30846 | 30 |
* @modules jdk.jdeps/com.sun.tools.classfile |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
15384
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.util |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
32 |
* @build JavacTestingAbstractThreadedTest |
15384
5a8d00abf076
8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents:
15040
diff
changeset
|
33 |
* @run main/othervm T7042566 |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
34 |
*/ |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
35 |
|
15384
5a8d00abf076
8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents:
15040
diff
changeset
|
36 |
// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047) |
5a8d00abf076
8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents:
15040
diff
changeset
|
37 |
// see JDK-8006746 |
5a8d00abf076
8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents:
15040
diff
changeset
|
38 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
39 |
import java.io.File; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
40 |
import java.net.URI; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
41 |
import java.util.Arrays; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
42 |
import java.util.Locale; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
43 |
import java.util.concurrent.atomic.AtomicInteger; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
44 |
import javax.tools.Diagnostic; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
45 |
import javax.tools.JavaCompiler; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
46 |
import javax.tools.JavaFileObject; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
47 |
import javax.tools.SimpleJavaFileObject; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
48 |
import javax.tools.ToolProvider; |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
49 |
|
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
50 |
import com.sun.source.util.JavacTask; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
51 |
import com.sun.tools.classfile.Instruction; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
52 |
import com.sun.tools.classfile.Attribute; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
53 |
import com.sun.tools.classfile.ClassFile; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
54 |
import com.sun.tools.classfile.Code_attribute; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
55 |
import com.sun.tools.classfile.ConstantPool.*; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
56 |
import com.sun.tools.classfile.Method; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
57 |
import com.sun.tools.javac.util.List; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
58 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
59 |
public class T7042566 |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
60 |
extends JavacTestingAbstractThreadedTest |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
61 |
implements Runnable { |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
62 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
63 |
VarargsMethod m1; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
64 |
VarargsMethod m2; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
65 |
TypeConfiguration actuals; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
66 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
67 |
T7042566(TypeConfiguration m1_conf, TypeConfiguration m2_conf, |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
68 |
TypeConfiguration actuals) { |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
69 |
this.m1 = new VarargsMethod(m1_conf); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
70 |
this.m2 = new VarargsMethod(m2_conf); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
71 |
this.actuals = actuals; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
72 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
73 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
74 |
@Override |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
75 |
public void run() { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
76 |
int id = checkCount.incrementAndGet(); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
77 |
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
78 |
JavaSource source = new JavaSource(id); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
79 |
ErrorChecker ec = new ErrorChecker(); |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
80 |
JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), ec, |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
81 |
null, null, Arrays.asList(source)); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
82 |
ct.call(); |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
83 |
check(source, ec, id); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
84 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
85 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
86 |
void check(JavaSource source, ErrorChecker ec, int id) { |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
87 |
boolean resolutionError = false; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
88 |
VarargsMethod selectedMethod = null; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
89 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
90 |
boolean m1_applicable = m1.isApplicable(actuals); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
91 |
boolean m2_applicable = m2.isApplicable(actuals); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
92 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
93 |
if (!m1_applicable && !m2_applicable) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
94 |
resolutionError = true; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
95 |
} else if (m1_applicable && m2_applicable) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
96 |
//most specific |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
97 |
boolean m1_moreSpecific = m1.isMoreSpecificThan(m2); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
98 |
boolean m2_moreSpecific = m2.isMoreSpecificThan(m1); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
99 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
100 |
resolutionError = m1_moreSpecific == m2_moreSpecific; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
101 |
selectedMethod = m1_moreSpecific ? m1 : m2; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
102 |
} else { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
103 |
selectedMethod = m1_applicable ? |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
104 |
m1 : m2; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
105 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
106 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
107 |
if (ec.errorFound != resolutionError) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
108 |
throw new Error("invalid diagnostics for source:\n" + |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
109 |
source.getCharContent(true) + |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
110 |
"\nExpected resolution error: " + resolutionError + |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
111 |
"\nFound error: " + ec.errorFound + |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
112 |
"\nCompiler diagnostics:\n" + ec.printDiags()); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
113 |
} else if (!resolutionError) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
114 |
verifyBytecode(selectedMethod, source, id); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
115 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
116 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
117 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
118 |
void verifyBytecode(VarargsMethod selected, JavaSource source, int id) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
119 |
bytecodeCheckCount.incrementAndGet(); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
120 |
File compiledTest = new File(String.format("Test%d.class", id)); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
121 |
try { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
122 |
ClassFile cf = ClassFile.read(compiledTest); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
123 |
Method testMethod = null; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
124 |
for (Method m : cf.methods) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
125 |
if (m.getName(cf.constant_pool).equals("test")) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
126 |
testMethod = m; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
127 |
break; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
128 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
129 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
130 |
if (testMethod == null) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
131 |
throw new Error("Test method not found"); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
132 |
} |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
133 |
Code_attribute ea = |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
134 |
(Code_attribute)testMethod.attributes.get(Attribute.Code); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
135 |
if (testMethod == null) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
136 |
throw new Error("Code attribute for test() method not found"); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
137 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
138 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
139 |
for (Instruction i : ea.getInstructions()) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
140 |
if (i.getMnemonic().equals("invokevirtual")) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
141 |
int cp_entry = i.getUnsignedShort(1); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
142 |
CONSTANT_Methodref_info methRef = |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
143 |
(CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
144 |
String type = methRef.getNameAndTypeInfo().getType(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
145 |
String sig = selected.parameterTypes.bytecodeSigStr; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
146 |
if (!type.contains(sig)) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
147 |
throw new Error("Unexpected type method call: " + |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
148 |
type + "" + |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
149 |
"\nfound: " + sig + |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
150 |
"\n" + source.getCharContent(true)); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
151 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
152 |
break; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
153 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
154 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
155 |
} catch (Exception e) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
156 |
e.printStackTrace(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
157 |
throw new Error("error reading " + compiledTest +": " + e); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
158 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
159 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
160 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
161 |
class JavaSource extends SimpleJavaFileObject { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
162 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
163 |
static final String source_template = "class Test#ID {\n" + |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
164 |
" #V1\n" + |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
165 |
" #V2\n" + |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
166 |
" void test() { m(#E); }\n" + |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
167 |
"}"; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
168 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
169 |
String source; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
170 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
171 |
public JavaSource(int id) { |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
172 |
super(URI.create(String.format("myfo:/Test%d.java", id)), |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
173 |
JavaFileObject.Kind.SOURCE); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
174 |
source = source_template.replaceAll("#V1", m1.toString()) |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
175 |
.replaceAll("#V2", m2.toString()) |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
176 |
.replaceAll("#E", actuals.expressionListStr) |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
177 |
.replaceAll("#ID", String.valueOf(id)); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
178 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
179 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
180 |
@Override |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
181 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
182 |
return source; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
183 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
184 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
185 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
186 |
public static void main(String... args) throws Exception { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
187 |
for (TypeConfiguration tconf1 : TypeConfiguration.values()) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
188 |
for (TypeConfiguration tconf2 : TypeConfiguration.values()) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
189 |
for (TypeConfiguration tconf3 : TypeConfiguration.values()) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
190 |
pool.execute(new T7042566(tconf1, tconf2, tconf3)); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
191 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
192 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
193 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
194 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
195 |
outWriter.println("Bytecode checks made: " + bytecodeCheckCount.get()); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
196 |
checkAfterExec(); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
197 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
198 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
199 |
enum TypeKind { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
200 |
OBJECT("Object", "(Object)null", "Ljava/lang/Object;"), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
201 |
STRING("String", "(String)null", "Ljava/lang/String;"); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
202 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
203 |
String typeString; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
204 |
String valueString; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
205 |
String bytecodeString; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
206 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
207 |
TypeKind(String typeString, String valueString, String bytecodeString) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
208 |
this.typeString = typeString; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
209 |
this.valueString = valueString; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
210 |
this.bytecodeString = bytecodeString; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
211 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
212 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
213 |
boolean isSubtypeOf(TypeKind that) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
214 |
return that == OBJECT || |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
215 |
(that == STRING && this == STRING); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
216 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
217 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
218 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
219 |
enum TypeConfiguration { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
220 |
A(TypeKind.OBJECT), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
221 |
B(TypeKind.STRING), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
222 |
AA(TypeKind.OBJECT, TypeKind.OBJECT), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
223 |
AB(TypeKind.OBJECT, TypeKind.STRING), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
224 |
BA(TypeKind.STRING, TypeKind.OBJECT), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
225 |
BB(TypeKind.STRING, TypeKind.STRING), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
226 |
AAA(TypeKind.OBJECT, TypeKind.OBJECT, TypeKind.OBJECT), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
227 |
AAB(TypeKind.OBJECT, TypeKind.OBJECT, TypeKind.STRING), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
228 |
ABA(TypeKind.OBJECT, TypeKind.STRING, TypeKind.OBJECT), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
229 |
ABB(TypeKind.OBJECT, TypeKind.STRING, TypeKind.STRING), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
230 |
BAA(TypeKind.STRING, TypeKind.OBJECT, TypeKind.OBJECT), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
231 |
BAB(TypeKind.STRING, TypeKind.OBJECT, TypeKind.STRING), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
232 |
BBA(TypeKind.STRING, TypeKind.STRING, TypeKind.OBJECT), |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
233 |
BBB(TypeKind.STRING, TypeKind.STRING, TypeKind.STRING); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
234 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
235 |
List<TypeKind> typeKindList; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
236 |
String expressionListStr; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
237 |
String parameterListStr; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
238 |
String bytecodeSigStr; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
239 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
240 |
private TypeConfiguration(TypeKind... typeKindList) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
241 |
this.typeKindList = List.from(typeKindList); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
242 |
expressionListStr = asExpressionList(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
243 |
parameterListStr = asParameterList(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
244 |
bytecodeSigStr = asBytecodeString(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
245 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
246 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
247 |
private String asExpressionList() { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
248 |
StringBuilder buf = new StringBuilder(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
249 |
String sep = ""; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
250 |
for (TypeKind tk : typeKindList) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
251 |
buf.append(sep); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
252 |
buf.append(tk.valueString); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
253 |
sep = ","; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
254 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
255 |
return buf.toString(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
256 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
257 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
258 |
private String asParameterList() { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
259 |
StringBuilder buf = new StringBuilder(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
260 |
String sep = ""; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
261 |
int count = 0; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
262 |
for (TypeKind arg : typeKindList) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
263 |
buf.append(sep); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
264 |
buf.append(arg.typeString); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
265 |
if (count == (typeKindList.size() - 1)) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
266 |
buf.append("..."); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
267 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
268 |
buf.append(" "); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
269 |
buf.append("arg" + count++); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
270 |
sep = ","; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
271 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
272 |
return buf.toString(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
273 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
274 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
275 |
private String asBytecodeString() { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
276 |
StringBuilder buf = new StringBuilder(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
277 |
int count = 0; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
278 |
for (TypeKind arg : typeKindList) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
279 |
if (count == (typeKindList.size() - 1)) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
280 |
buf.append("["); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
281 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
282 |
buf.append(arg.bytecodeString); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
283 |
count++; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
284 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
285 |
return buf.toString(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
286 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
287 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
288 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
289 |
static class VarargsMethod { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
290 |
TypeConfiguration parameterTypes; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
291 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
292 |
public VarargsMethod(TypeConfiguration parameterTypes) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
293 |
this.parameterTypes = parameterTypes; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
294 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
295 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
296 |
@Override |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
297 |
public String toString() { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
298 |
return "void m( " + parameterTypes.parameterListStr + ") {}"; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
299 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
300 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
301 |
boolean isApplicable(TypeConfiguration that) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
302 |
List<TypeKind> actuals = that.typeKindList; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
303 |
List<TypeKind> formals = parameterTypes.typeKindList; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
304 |
if ((actuals.size() - formals.size()) < -1) |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
305 |
return false; //not enough args |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
306 |
for (TypeKind actual : actuals) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
307 |
if (!actual.isSubtypeOf(formals.head)) |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
308 |
return false; //type mismatch |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
309 |
formals = formals.tail.isEmpty() ? |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
310 |
formals : |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
311 |
formals.tail; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
312 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
313 |
return true; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
314 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
315 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
316 |
boolean isMoreSpecificThan(VarargsMethod that) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
317 |
List<TypeKind> actuals = parameterTypes.typeKindList; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
318 |
List<TypeKind> formals = that.parameterTypes.typeKindList; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
319 |
int checks = 0; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
320 |
int expectedCheck = Math.max(actuals.size(), formals.size()); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
321 |
while (checks < expectedCheck) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
322 |
if (!actuals.head.isSubtypeOf(formals.head)) |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
323 |
return false; //type mismatch |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
324 |
formals = formals.tail.isEmpty() ? |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
325 |
formals : |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
326 |
formals.tail; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
327 |
actuals = actuals.tail.isEmpty() ? |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
328 |
actuals : |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
329 |
actuals.tail; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
330 |
checks++; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
331 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
332 |
return true; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
333 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
334 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
335 |
|
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
336 |
static class ErrorChecker |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
337 |
implements javax.tools.DiagnosticListener<JavaFileObject> { |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
338 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
339 |
boolean errorFound; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
340 |
List<String> errDiags = List.nil(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
341 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
342 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
343 |
if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
344 |
errDiags = errDiags |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
345 |
.append(diagnostic.getMessage(Locale.getDefault())); |
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
346 |
errorFound = true; |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
347 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
348 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
349 |
|
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
350 |
String printDiags() { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
351 |
StringBuilder buf = new StringBuilder(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
352 |
for (String s : errDiags) { |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
353 |
buf.append(s); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
354 |
buf.append("\n"); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
355 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
356 |
return buf.toString(); |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
357 |
} |
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
358 |
} |
15040
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
359 |
|
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
360 |
//number of bytecode checks made while running combo tests |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
361 |
static AtomicInteger bytecodeCheckCount = new AtomicInteger(); |
99fd9483d3f0
8005167: execution time of combo tests in javac should be improved
vromero
parents:
9720
diff
changeset
|
362 |
|
9720
bc06a797f393
7042566: Regression: new ambiguity between varargs method
mcimadamore
parents:
diff
changeset
|
363 |
} |