author | mcimadamore |
Tue, 13 Sep 2011 14:15:39 +0100 | |
changeset 10628 | dca7012223bc |
child 11381 | 890ea587d133 |
permissions | -rw-r--r-- |
10628
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
1 |
/* |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
4 |
* |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
8 |
* |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
14 |
* |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
18 |
* |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
23 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
24 |
/* |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
26 |
* @bug 7086601 |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
27 |
* @summary Error message bug: cause for method mismatch is 'null' |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
28 |
*/ |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
29 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
30 |
import com.sun.source.util.JavacTask; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
31 |
import java.net.URI; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
32 |
import java.util.Arrays; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
33 |
import java.util.ArrayList; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
34 |
import javax.tools.Diagnostic; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
35 |
import javax.tools.JavaCompiler; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
36 |
import javax.tools.JavaFileObject; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
37 |
import javax.tools.SimpleJavaFileObject; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
38 |
import javax.tools.StandardJavaFileManager; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
39 |
import javax.tools.ToolProvider; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
40 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
41 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
42 |
public class T7086601b { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
43 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
44 |
static int checkCount = 0; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
45 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
46 |
enum TypeKind { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
47 |
STRING("String", false), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
48 |
INTEGER("Integer", false), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
49 |
NUMBER("Number", false), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
50 |
SERIALIZABLE("java.io.Serializable", true), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
51 |
CLONEABLE("Cloneable", true), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
52 |
X("X", false), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
53 |
Y("Y", false), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
54 |
Z("Z", false); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
55 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
56 |
String typeStr; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
57 |
boolean isInterface; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
58 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
59 |
private TypeKind(String typeStr, boolean isInterface) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
60 |
this.typeStr = typeStr; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
61 |
this.isInterface = isInterface; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
62 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
63 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
64 |
boolean isSubtypeof(TypeKind other) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
65 |
return (this == INTEGER && other == NUMBER || |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
66 |
this == Z && other == Y || |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
67 |
this == other); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
68 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
69 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
70 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
71 |
enum MethodCallKind { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
72 |
ARITY_ONE("m(a1);", 1), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
73 |
ARITY_TWO("m(a1, a2);", 2), |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
74 |
ARITY_THREE("m(a1, a2, a3);", 3); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
75 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
76 |
String invokeString; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
77 |
int arity; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
78 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
79 |
private MethodCallKind(String invokeString, int arity) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
80 |
this.invokeString = invokeString; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
81 |
this.arity = arity; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
82 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
83 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
84 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
85 |
public static void main(String... args) throws Exception { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
86 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
87 |
//create default shared JavaCompiler - reused across multiple compilations |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
88 |
JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
89 |
StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
90 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
91 |
for (TypeKind a1 : TypeKind.values()) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
92 |
for (TypeKind a2 : TypeKind.values()) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
93 |
for (TypeKind a3 : TypeKind.values()) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
94 |
for (MethodCallKind mck : MethodCallKind.values()) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
95 |
new T7086601b(a1, a2, a3, mck).run(comp, fm); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
96 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
97 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
98 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
99 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
100 |
System.out.println("Total check executed: " + checkCount); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
101 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
102 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
103 |
TypeKind a1; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
104 |
TypeKind a2; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
105 |
TypeKind a3; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
106 |
MethodCallKind mck; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
107 |
JavaSource source; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
108 |
DiagnosticChecker diagChecker; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
109 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
110 |
T7086601b(TypeKind a1, TypeKind a2, TypeKind a3, MethodCallKind mck) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
111 |
this.a1 = a1; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
112 |
this.a2 = a2; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
113 |
this.a3 = a3; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
114 |
this.mck = mck; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
115 |
this.source = new JavaSource(); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
116 |
this.diagChecker = new DiagnosticChecker(); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
117 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
118 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
119 |
class JavaSource extends SimpleJavaFileObject { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
120 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
121 |
final String bodyTemplate = "import java.util.List;\n"+ |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
122 |
"class Test {\n" + |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
123 |
" <Z> void m(List<? super Z> l1) { }\n" + |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
124 |
" <Z> void m(List<? super Z> l1, List<? super Z> l2) { }\n" + |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
125 |
" <Z> void m(List<? super Z> l1, List<? super Z> l2, List<? super Z> l3) { }\n" + |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
126 |
" <X,Y,Z extends Y> void test(List<#A1> a1, List<#A2> a2, List<#A3> a3) { #MC } }"; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
127 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
128 |
String source; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
129 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
130 |
public JavaSource() { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
131 |
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
132 |
source = bodyTemplate.replace("#A1", a1.typeStr) |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
133 |
.replace("#A2", a2.typeStr).replace("#A3", a3.typeStr) |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
134 |
.replace("#MC", mck.invokeString); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
135 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
136 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
137 |
@Override |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
138 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
139 |
return source; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
140 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
141 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
142 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
143 |
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
144 |
JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker, |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
145 |
null, null, Arrays.asList(source)); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
146 |
try { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
147 |
ct.analyze(); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
148 |
} catch (Throwable ex) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
149 |
throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true)); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
150 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
151 |
check(); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
152 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
153 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
154 |
void check() { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
155 |
checkCount++; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
156 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
157 |
boolean errorExpected = false; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
158 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
159 |
if (mck.arity > 1) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
160 |
TypeKind[] argtypes = { a1, a2, a3 }; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
161 |
ArrayList<TypeKind> classes = new ArrayList<>(); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
162 |
for (int i = 0 ; i < mck.arity ; i ++ ) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
163 |
if (!argtypes[i].isInterface) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
164 |
classes.add(argtypes[i]); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
165 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
166 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
167 |
boolean glb_exists = true; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
168 |
for (TypeKind arg_i : classes) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
169 |
glb_exists = true; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
170 |
for (TypeKind arg_j : classes) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
171 |
if (!arg_i.isSubtypeof(arg_j)) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
172 |
glb_exists = false; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
173 |
break; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
174 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
175 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
176 |
if (glb_exists) break; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
177 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
178 |
errorExpected = !glb_exists; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
179 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
180 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
181 |
if (errorExpected != diagChecker.errorFound) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
182 |
throw new Error("invalid diagnostics for source:\n" + |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
183 |
source.getCharContent(true) + |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
184 |
"\nFound error: " + diagChecker.errorFound + |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
185 |
"\nExpected error: " + errorExpected); |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
186 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
187 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
188 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
189 |
static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
190 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
191 |
boolean errorFound; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
192 |
|
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
193 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
194 |
if (diagnostic.getKind() == Diagnostic.Kind.ERROR) { |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
195 |
errorFound = true; |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
196 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
197 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
198 |
} |
dca7012223bc
7086601: Error message bug: cause for method mismatch is 'null'
mcimadamore
parents:
diff
changeset
|
199 |
} |