author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 25440 | 7f9cedf2e88d |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
25440
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
25440
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
25440
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
4 |
* |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
8 |
* |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
14 |
* |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
18 |
* |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
22 |
*/ |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
23 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
24 |
/* |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
25 |
* @test |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
26 |
* @bug 8042239 |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
27 |
* @summary Verify that TreeMaker.Type(Type) can handle all reasonable types |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
28 |
* @library /tools/javac/lib |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
25440
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
25440
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.code |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
25440
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.processing |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
25440
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.tree |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
25440
diff
changeset
|
33 |
* jdk.compiler/com.sun.tools.javac.util |
25440
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
34 |
* @build JavacTestingAbstractProcessor MakeTypeTest |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
35 |
* @compile/process/ref=MakeTypeTest.out -processor MakeTypeTest MakeTypeTest.java |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
36 |
*/ |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
37 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
38 |
import java.lang.annotation.*; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
39 |
import java.util.*; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
40 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
41 |
import javax.annotation.processing.RoundEnvironment; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
42 |
import javax.lang.model.element.*; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
43 |
import javax.lang.model.type.*; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
44 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
45 |
import com.sun.source.tree.*; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
46 |
import com.sun.source.util.*; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
47 |
import com.sun.tools.javac.api.JavacTrees; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
48 |
import com.sun.tools.javac.code.Type; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
49 |
import com.sun.tools.javac.code.Type.ClassType; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
50 |
import com.sun.tools.javac.processing.JavacProcessingEnvironment; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
51 |
import com.sun.tools.javac.tree.JCTree.JCExpression; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
52 |
import com.sun.tools.javac.tree.TreeMaker; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
53 |
import com.sun.tools.javac.util.*; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
54 |
import com.sun.tools.javac.util.List; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
55 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
56 |
public class MakeTypeTest extends JavacTestingAbstractProcessor { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
57 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
58 |
@Override |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
59 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
60 |
if (!roundEnv.processingOver()) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
61 |
return false; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
62 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
63 |
JavacTask.instance(processingEnv).addTaskListener(new TaskListener() { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
64 |
@Override |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
65 |
public void started(TaskEvent e) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
66 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
67 |
@Override |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
68 |
public void finished(TaskEvent e) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
69 |
if (e.getKind() == TaskEvent.Kind.ANALYZE && |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
70 |
e.getTypeElement().getQualifiedName().contentEquals("MakeTypeTest")) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
71 |
doTest(); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
72 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
73 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
74 |
}); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
75 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
76 |
return false; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
77 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
78 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
79 |
void doTest() { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
80 |
//go through this file, look for @TestType and verify TreeMaker.Type behavior: |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
81 |
Context ctx = ((JavacProcessingEnvironment) processingEnv).getContext(); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
82 |
JavacTrees trees = JavacTrees.instance(ctx); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
83 |
TypeElement testType = processingEnv.getElementUtils().getTypeElement("MakeTypeTest"); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
84 |
TreePath path = trees.getPath(testType); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
85 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
86 |
Set<TypeKind> unseenTypeKinds = EnumSet.allOf(TypeKind.class); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
87 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
88 |
new TreePathScanner<Void, Void>() { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
89 |
@Override |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
90 |
public Void visitVariable(VariableTree node, Void p) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
91 |
handleDecl(new TreePath(getCurrentPath(), node.getType())); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
92 |
return super.visitVariable(node, p); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
93 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
94 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
95 |
@Override |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
96 |
public Void visitMethod(MethodTree node, Void p) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
97 |
if (node.getReturnType() != null) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
98 |
handleDecl(new TreePath(getCurrentPath(), node.getReturnType())); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
99 |
return super.visitMethod(node, p); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
100 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
101 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
102 |
@Override |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
103 |
public Void visitTypeParameter(TypeParameterTree node, Void p) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
104 |
TypeVariable type = (TypeVariable) trees.getTypeMirror(getCurrentPath()); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
105 |
TreePath aBoundPath = new TreePath(getCurrentPath(), node.getBounds().get(0)); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
106 |
handleDecl(aBoundPath, (Type) type.getUpperBound()); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
107 |
return super.visitTypeParameter(node, p); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
108 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
109 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
110 |
void handleDecl(TreePath typePath) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
111 |
handleDecl(typePath, (Type) trees.getTypeMirror(typePath)); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
112 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
113 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
114 |
void handleDecl(TreePath typePath, Type type) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
115 |
Element decl = trees.getElement(typePath.getParentPath()); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
116 |
TestType testType = decl.getAnnotation(TestType.class); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
117 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
118 |
if (testType == null) return ; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
119 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
120 |
if (testType.nested() >= 0) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
121 |
ClassType ct = (ClassType) type; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
122 |
type = ct.getTypeArguments().get(testType.nested()); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
123 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
124 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
125 |
JCExpression typeExpr = TreeMaker.instance(ctx).Type(type); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
126 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
127 |
if (!typeExpr.getKind().equals(testType.expectedKind())) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
128 |
throw new IllegalStateException("was=" + typeExpr + ", kind=" + |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
129 |
typeExpr.getKind() + "; expected kind: " + |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
130 |
testType.expectedKind() + "; type=" + type); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
131 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
132 |
unseenTypeKinds.remove(type.getKind()); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
133 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
134 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
135 |
}.scan(path, null); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
136 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
137 |
unseenTypeKinds.removeAll(Arrays.asList(TypeKind.NONE, TypeKind.NULL, TypeKind.ERROR, |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
138 |
TypeKind.PACKAGE, TypeKind.EXECUTABLE, TypeKind.OTHER)); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
139 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
140 |
if (!unseenTypeKinds.isEmpty()) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
141 |
throw new IllegalStateException("Unhandled types=" + unseenTypeKinds); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
142 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
143 |
System.err.println("done."); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
144 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
145 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
146 |
//the following defines the Types that should be passed into TreeMaker.Type and |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
147 |
//the expected resulting Tree kind: |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
148 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
149 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
150 |
boolean f1; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
151 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
152 |
byte f2; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
153 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
154 |
char f3; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
155 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
156 |
double f4; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
157 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
158 |
float f5; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
159 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
160 |
int f6; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
161 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
162 |
long f7; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
163 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
164 |
short f8; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
165 |
@TestType(expectedKind=Tree.Kind.PARAMETERIZED_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
166 |
List<? extends String> f9; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
167 |
@TestType(expectedKind=Tree.Kind.ARRAY_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
168 |
int[] fa; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
169 |
@TestType(expectedKind=Tree.Kind.EXTENDS_WILDCARD, nested = 0) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
170 |
List<? extends String> fb; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
171 |
@TestType(expectedKind=Tree.Kind.SUPER_WILDCARD, nested = 0) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
172 |
List<? super String> fc; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
173 |
@TestType(expectedKind=Tree.Kind.UNBOUNDED_WILDCARD, nested = 0) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
174 |
List<?> fd; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
175 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
176 |
@TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
177 |
void voidMethod() { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
178 |
try { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
179 |
voidMethod(); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
180 |
} catch (@TestType(expectedKind=Tree.Kind.UNION_TYPE) NullPointerException | |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
181 |
IllegalStateException ex) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
182 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
183 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
184 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
185 |
class WithTypeParam<@TestType(expectedKind=Tree.Kind.INTERSECTION_TYPE) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
186 |
T extends CharSequence & Runnable> { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
187 |
@TestType(expectedKind=Tree.Kind.IDENTIFIER) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
188 |
T voidMethod() { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
189 |
return null; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
190 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
191 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
192 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
193 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
194 |
|
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
195 |
//TreeMaker.Type will be tested for the type the element annotated by this annotation |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
196 |
@Target({ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
197 |
ElementType.PARAMETER, ElementType.TYPE_PARAMETER}) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
198 |
@interface TestType { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
199 |
//the expected Tree kind of the Tree that will be returned from TreeMaker.Type for the type |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
200 |
public Tree.Kind expectedKind(); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
201 |
//if >=0, the current type will be interpreted as a ClassType and the type to test will be |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
202 |
//the given type argument: |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
203 |
public int nested() default -1; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
diff
changeset
|
204 |
} |