author | aph |
Mon, 04 Nov 2019 13:13:34 -0500 | |
changeset 58917 | 33f9271b3167 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
2 |
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5520 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
10 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 6341023 |
|
27 |
* @summary Tree API: Tree.Kind should have mapping to interface |
|
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
15385
diff
changeset
|
28 |
* @modules jdk.compiler |
10 | 29 |
*/ |
30 |
||
31 |
import com.sun.source.tree.*; |
|
32 |
||
15385 | 33 |
public class TreeKindTest { |
10 | 34 |
public static void main(String... args) { |
35 |
boolean ok = true; |
|
36 |
||
37 |
for (Tree.Kind k: Tree.Kind.values()) { |
|
38 |
//System.err.println(k + " " + k.asInterface()); |
|
39 |
Class<? extends Tree> i = k.asInterface(); |
|
40 |
switch (k) { |
|
41 |
case POSTFIX_INCREMENT: |
|
42 |
case POSTFIX_DECREMENT: |
|
43 |
case PREFIX_INCREMENT: |
|
44 |
case PREFIX_DECREMENT: |
|
45 |
case UNARY_PLUS: |
|
46 |
case UNARY_MINUS: |
|
47 |
case BITWISE_COMPLEMENT: |
|
48 |
case LOGICAL_COMPLEMENT: |
|
49 |
ok = ok & verify(k, i, i == UnaryTree.class); |
|
50 |
break; |
|
51 |
||
52 |
case MULTIPLY: |
|
53 |
case DIVIDE: |
|
54 |
case REMAINDER: |
|
55 |
case PLUS: |
|
56 |
case MINUS: |
|
57 |
case LEFT_SHIFT: |
|
58 |
case RIGHT_SHIFT: |
|
59 |
case UNSIGNED_RIGHT_SHIFT: |
|
60 |
case LESS_THAN: |
|
61 |
case GREATER_THAN: |
|
62 |
case LESS_THAN_EQUAL: |
|
63 |
case GREATER_THAN_EQUAL: |
|
64 |
case EQUAL_TO: |
|
65 |
case NOT_EQUAL_TO: |
|
66 |
case AND: |
|
67 |
case XOR: |
|
68 |
case OR: |
|
69 |
case CONDITIONAL_AND: |
|
70 |
case CONDITIONAL_OR: |
|
71 |
ok = ok & verify(k, i, i == BinaryTree.class); |
|
72 |
break; |
|
73 |
||
74 |
case MULTIPLY_ASSIGNMENT: |
|
75 |
case DIVIDE_ASSIGNMENT: |
|
76 |
case REMAINDER_ASSIGNMENT: |
|
77 |
case PLUS_ASSIGNMENT: |
|
78 |
case MINUS_ASSIGNMENT: |
|
79 |
case LEFT_SHIFT_ASSIGNMENT: |
|
80 |
case RIGHT_SHIFT_ASSIGNMENT: |
|
81 |
case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT: |
|
82 |
case AND_ASSIGNMENT: |
|
83 |
case XOR_ASSIGNMENT: |
|
84 |
case OR_ASSIGNMENT: |
|
85 |
ok = ok & verify(k, i, i == CompoundAssignmentTree.class); |
|
86 |
break; |
|
87 |
||
88 |
case INT_LITERAL: |
|
89 |
case LONG_LITERAL: |
|
90 |
case FLOAT_LITERAL: |
|
91 |
case DOUBLE_LITERAL: |
|
92 |
case BOOLEAN_LITERAL: |
|
93 |
case CHAR_LITERAL: |
|
94 |
case STRING_LITERAL: |
|
95 |
case NULL_LITERAL: |
|
96 |
ok = ok & verify(k, i, i == LiteralTree.class); |
|
97 |
break; |
|
98 |
||
99 |
case UNBOUNDED_WILDCARD: |
|
100 |
case EXTENDS_WILDCARD: |
|
101 |
case SUPER_WILDCARD: |
|
102 |
ok = ok & verify(k, i, i == WildcardTree.class); |
|
103 |
break; |
|
104 |
||
6580
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
5520
diff
changeset
|
105 |
case INTERFACE: |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
5520
diff
changeset
|
106 |
case ANNOTATION_TYPE: |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
5520
diff
changeset
|
107 |
case ENUM: |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
5520
diff
changeset
|
108 |
case CLASS: |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
5520
diff
changeset
|
109 |
ok = ok & verify(k, i, i == ClassTree.class); |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
5520
diff
changeset
|
110 |
break; |
d3d578d22cc7
6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents:
5520
diff
changeset
|
111 |
|
15385 | 112 |
case ANNOTATION: |
113 |
case TYPE_ANNOTATION: |
|
114 |
ok = ok & verify(k, i, i == AnnotationTree.class); |
|
115 |
break; |
|
116 |
||
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
117 |
case EXPORTS: |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
118 |
ok = ok & verify(k, i, i == ExportsTree.class); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
119 |
break; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
120 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
121 |
case OPENS: |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
122 |
ok = ok & verify(k, i, i == OpensTree.class); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
123 |
break; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
30730
diff
changeset
|
124 |
|
10 | 125 |
case OTHER: |
126 |
ok = ok & verify(k, i, i == null); |
|
127 |
break; |
|
128 |
||
129 |
default: |
|
130 |
String ks = k.toString().replace("_", "") + "tree"; |
|
131 |
String iName = i.getName(); |
|
132 |
String is = iName.substring(iName.lastIndexOf(".") + 1); |
|
133 |
ok = ok & verify(k, i, ks.equalsIgnoreCase(is)); |
|
134 |
} |
|
135 |
} |
|
136 |
||
137 |
if (!ok) |
|
138 |
throw new AssertionError("test failed"); |
|
139 |
} |
|
140 |
||
141 |
static boolean verify(Tree.Kind k, Class<?> c, boolean b) { |
|
142 |
if (!b) |
|
143 |
System.err.println("error: " + k + " " + c); |
|
144 |
return b; |
|
145 |
} |
|
146 |
} |