1 | /*
|
---|
2 | * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
---|
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 | *
|
---|
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.
|
---|
22 | */
|
---|
23 |
|
---|
24 | /*
|
---|
25 | * @test
|
---|
26 | * @bug 6341023
|
---|
27 | * @summary Tree API: Tree.Kind should have mapping to interface
|
---|
28 | */
|
---|
29 |
|
---|
30 | import com.sun.source.tree.*;
|
---|
31 |
|
---|
32 | public class T6341023 {
|
---|
33 | public static void main(String... args) {
|
---|
34 | boolean ok = true;
|
---|
35 |
|
---|
36 | for (Tree.Kind k: Tree.Kind.values()) {
|
---|
37 | //System.err.println(k + " " + k.asInterface());
|
---|
38 | Class<? extends Tree> i = k.asInterface();
|
---|
39 | switch (k) {
|
---|
40 | case POSTFIX_INCREMENT:
|
---|
41 | case POSTFIX_DECREMENT:
|
---|
42 | case PREFIX_INCREMENT:
|
---|
43 | case PREFIX_DECREMENT:
|
---|
44 | case UNARY_PLUS:
|
---|
45 | case UNARY_MINUS:
|
---|
46 | case BITWISE_COMPLEMENT:
|
---|
47 | case LOGICAL_COMPLEMENT:
|
---|
48 | ok = ok & verify(k, i, i == UnaryTree.class);
|
---|
49 | break;
|
---|
50 |
|
---|
51 | case MULTIPLY:
|
---|
52 | case DIVIDE:
|
---|
53 | case REMAINDER:
|
---|
54 | case PLUS:
|
---|
55 | case MINUS:
|
---|
56 | case LEFT_SHIFT:
|
---|
57 | case RIGHT_SHIFT:
|
---|
58 | case UNSIGNED_RIGHT_SHIFT:
|
---|
59 | case LESS_THAN:
|
---|
60 | case GREATER_THAN:
|
---|
61 | case LESS_THAN_EQUAL:
|
---|
62 | case GREATER_THAN_EQUAL:
|
---|
63 | case EQUAL_TO:
|
---|
64 | case NOT_EQUAL_TO:
|
---|
65 | case AND:
|
---|
66 | case XOR:
|
---|
67 | case OR:
|
---|
68 | case CONDITIONAL_AND:
|
---|
69 | case CONDITIONAL_OR:
|
---|
70 | ok = ok & verify(k, i, i == BinaryTree.class);
|
---|
71 | break;
|
---|
72 |
|
---|
73 | case MULTIPLY_ASSIGNMENT:
|
---|
74 | case DIVIDE_ASSIGNMENT:
|
---|
75 | case REMAINDER_ASSIGNMENT:
|
---|
76 | case PLUS_ASSIGNMENT:
|
---|
77 | case MINUS_ASSIGNMENT:
|
---|
78 | case LEFT_SHIFT_ASSIGNMENT:
|
---|
79 | case RIGHT_SHIFT_ASSIGNMENT:
|
---|
80 | case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
|
---|
81 | case AND_ASSIGNMENT:
|
---|
82 | case XOR_ASSIGNMENT:
|
---|
83 | case OR_ASSIGNMENT:
|
---|
84 | ok = ok & verify(k, i, i == CompoundAssignmentTree.class);
|
---|
85 | break;
|
---|
86 |
|
---|
87 | case INT_LITERAL:
|
---|
88 | case LONG_LITERAL:
|
---|
89 | case FLOAT_LITERAL:
|
---|
90 | case DOUBLE_LITERAL:
|
---|
91 | case BOOLEAN_LITERAL:
|
---|
92 | case CHAR_LITERAL:
|
---|
93 | case STRING_LITERAL:
|
---|
94 | case NULL_LITERAL:
|
---|
95 | ok = ok & verify(k, i, i == LiteralTree.class);
|
---|
96 | break;
|
---|
97 |
|
---|
98 | case UNBOUNDED_WILDCARD:
|
---|
99 | case EXTENDS_WILDCARD:
|
---|
100 | case SUPER_WILDCARD:
|
---|
101 | ok = ok & verify(k, i, i == WildcardTree.class);
|
---|
102 | break;
|
---|
103 |
|
---|
104 | case OTHER:
|
---|
105 | ok = ok & verify(k, i, i == null);
|
---|
106 | break;
|
---|
107 |
|
---|
108 | default:
|
---|
109 | String ks = k.toString().replace("_", "") + "tree";
|
---|
110 | String iName = i.getName();
|
---|
111 | String is = iName.substring(iName.lastIndexOf(".") + 1);
|
---|
112 | ok = ok & verify(k, i, ks.equalsIgnoreCase(is));
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 | if (!ok)
|
---|
117 | throw new AssertionError("test failed");
|
---|
118 | }
|
---|
119 |
|
---|
120 | static boolean verify(Tree.Kind k, Class<?> c, boolean b) {
|
---|
121 | if (!b)
|
---|
122 | System.err.println("error: " + k + " " + c);
|
---|
123 | return b;
|
---|
124 | }
|
---|
125 | }
|
---|