author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 27544 | 78713cf9fa0b |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
27544
diff
changeset
|
2 |
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
4 |
* |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
8 |
* |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
13 |
* accompanied this code). |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
14 |
* |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
18 |
* |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
21 |
* questions. |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
22 |
*/ |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
23 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
24 |
/* |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
25 |
* @test |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
26 |
* @bug 6499673 |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
27 |
* @library /tools/javac/lib |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
27544
diff
changeset
|
28 |
* @modules jdk.compiler |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
29 |
* @build JavacTestingAbstractProcessor BoundsTest |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
30 |
* @run main BoundsTest |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
31 |
* @summary Assertion check for TypeVariable.getUpperBound() fails |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
32 |
*/ |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
33 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
34 |
import com.sun.source.util.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
35 |
import com.sun.tools.javac.api.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
36 |
import com.sun.tools.javac.file.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
37 |
import javax.annotation.processing.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
38 |
import javax.lang.model.SourceVersion; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
39 |
import javax.lang.model.type.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
40 |
import javax.lang.model.util.ElementFilter; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
41 |
import javax.lang.model.element.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
42 |
import javax.tools.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
43 |
import java.util.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
44 |
import java.io.*; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
45 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
46 |
public class BoundsTest { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
47 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
48 |
private int errors = 0; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
49 |
private static final String Intersection_name = "IntersectionTest.java"; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
50 |
private static final String Intersection_contents = |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
51 |
"import java.util.List;\n" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
52 |
"import java.io.Serializable;\t" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
53 |
"public class IntersectionTest<S extends List & Serializable> {\n" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
54 |
" void method(S s) { }\n" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
55 |
"}"; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
56 |
private static final String[] Intersection_bounds = { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
57 |
"java.util.List", |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
58 |
"java.io.Serializable" |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
59 |
}; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
60 |
private static final String[] Intersection_supers = { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
61 |
"java.util.List", |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
62 |
"java.io.Serializable" |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
63 |
}; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
64 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
65 |
private static final String Single_name = "SingleTest.java"; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
66 |
private static final String Single_contents = |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
67 |
"import java.util.List;\n" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
68 |
"public class SingleTest<S extends List> {\n" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
69 |
" void method(S s) { }\n" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
70 |
"}"; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
71 |
private static final String[] Single_bounds = { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
72 |
"java.util.List", |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
73 |
}; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
74 |
private static final String[] Single_supers = { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
75 |
"java.lang.Object", |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
76 |
"java.util.Collection" |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
77 |
}; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
78 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
79 |
private static final String NoBounds_name = "NoBoundsTest.java"; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
80 |
private static final String NoBounds_contents = |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
81 |
"public class NoBoundsTest<S> {\n" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
82 |
" void method(S s) { }\n" + |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
83 |
"}"; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
84 |
private static final String[] NoBounds_bounds = { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
85 |
"java.lang.Object", |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
86 |
}; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
87 |
private static final String[] NoBounds_supers = {}; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
88 |
|
27544 | 89 |
private HashSet<String> expected_bounds; |
90 |
private HashSet<String> expected_supers; |
|
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
91 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
92 |
private static final File classesdir = new File("intersectionproperties"); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
93 |
private static final JavaCompiler comp = |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
94 |
ToolProvider.getSystemJavaCompiler(); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
95 |
private static final StandardJavaFileManager fm = |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
96 |
comp.getStandardFileManager(null, null, null); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
97 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
98 |
public void runOne(final String Test_name, final String Test_contents, |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
99 |
final String[] Test_bounds, final String[] Test_supers) |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
100 |
throws IOException { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
101 |
System.err.println("Testing " + Test_name); |
27544 | 102 |
expected_bounds = new HashSet<>(Arrays.asList(Test_bounds)); |
103 |
expected_supers = new HashSet<>(Arrays.asList(Test_supers)); |
|
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
104 |
final Iterable<? extends JavaFileObject> files = |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
105 |
fm.getJavaFileObjectsFromFiles(Collections.singleton(writeFile(classesdir, Test_name, Test_contents))); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
106 |
final JavacTask ct = |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
107 |
(JavacTask)comp.getTask(null, fm, null, null, null, files); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
108 |
ct.setProcessors(Collections.singleton(new TestProcessor())); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
109 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
110 |
if (!ct.call()) { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
111 |
System.err.println("Compilation unexpectedly failed"); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
112 |
errors++; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
113 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
114 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
115 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
116 |
public void run() throws IOException { |
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
117 |
try { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
118 |
runOne(Intersection_name, Intersection_contents, |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
119 |
Intersection_bounds, Intersection_supers); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
120 |
runOne(Single_name, Single_contents, |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
121 |
Single_bounds, Single_supers); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
122 |
runOne(NoBounds_name, NoBounds_contents, |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
123 |
NoBounds_bounds, NoBounds_supers); |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
124 |
|
27319
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
125 |
if (0 != errors) |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
126 |
throw new RuntimeException(errors + " errors occurred"); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
127 |
} finally { |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
128 |
fm.close(); |
030080f03e4f
8062348: langtools tests should close file manager (group 1)
jjg
parents:
20252
diff
changeset
|
129 |
} |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
130 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
131 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
132 |
public static void main(String... args) throws IOException { |
27544 | 133 |
new BoundsTest().run(); |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
134 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
135 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
136 |
private static File writeFile(File dir, String path, String body) |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
137 |
throws IOException { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
138 |
File f = new File(dir, path); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
139 |
f.getParentFile().mkdirs(); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
140 |
try (FileWriter out = new FileWriter(f)) { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
141 |
out.write(body); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
142 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
143 |
return f; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
144 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
145 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
146 |
private class TestProcessor extends JavacTestingAbstractProcessor { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
147 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
148 |
private Set<? extends Element> rootElements; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
149 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
150 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
151 |
rootElements = roundEnv.getRootElements(); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
152 |
if (!rootElements.isEmpty()) { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
153 |
performCheck(); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
154 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
155 |
return true; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
156 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
157 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
158 |
private void performCheck() { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
159 |
TypeElement typeElement = (TypeElement) rootElements.iterator().next(); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
160 |
ExecutableElement method = ElementFilter.methodsIn(typeElement.getEnclosedElements()).get(0); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
161 |
TypeVariable typeVariable = (TypeVariable) method.getParameters().get(0).asType(); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
162 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
163 |
final TypeMirror upperBound = typeVariable.getUpperBound(); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
164 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
165 |
TypeParameterElement typeParameterElement = ((TypeParameterElement) typeVariable.asElement()); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
166 |
final List<? extends TypeMirror> bounds = typeParameterElement.getBounds(); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
167 |
final List<? extends TypeMirror> supers = processingEnv.getTypeUtils().directSupertypes(upperBound); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
168 |
|
27544 | 169 |
final HashSet<String> actual_bounds = new HashSet<>(); |
170 |
final HashSet<String> actual_supers = new HashSet<>(); |
|
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
171 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
172 |
for(TypeMirror ty : bounds) { |
27544 | 173 |
actual_bounds.add(((TypeElement)((DeclaredType)ty).asElement()).getQualifiedName().toString()); |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
174 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
175 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
176 |
for(TypeMirror ty : supers) { |
27544 | 177 |
actual_supers.add(((TypeElement)((DeclaredType)ty).asElement()).getQualifiedName().toString()); |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
178 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
179 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
180 |
if (!expected_bounds.equals(actual_bounds)) { |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
181 |
System.err.println("Mismatched expected and actual bounds."); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
182 |
System.err.println("Expected:"); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
183 |
for(CharSequence tm : expected_bounds) |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
184 |
System.err.println(" " + tm); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
185 |
System.err.println("Actual:"); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
186 |
for(CharSequence tm : actual_bounds) |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
187 |
System.err.println(" " + tm); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
188 |
errors++; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
189 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
190 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
191 |
if (!expected_supers.equals(actual_supers)) { |
27544 | 192 |
System.err.println("Mismatched expected and actual supers."); |
20252
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
193 |
System.err.println("Expected:"); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
194 |
for(CharSequence tm : expected_supers) |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
195 |
System.err.println(" " + tm); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
196 |
System.err.println("Actual:"); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
197 |
for(CharSequence tm : actual_supers) |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
198 |
System.err.println(" " + tm); |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
199 |
errors++; |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
200 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
201 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
202 |
} |
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
203 |
|
fae5c47ba7a4
6499673: Assertion check for TypeVariable.getUpperBound() fails.
emc
parents:
diff
changeset
|
204 |
} |