duke@1: /* duke@1: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as duke@1: * published by the Free Software Foundation. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * duke@1: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: * CA 95054 USA or visit www.sun.com if you need additional information or duke@1: * have any questions. duke@1: */ duke@1: duke@1: /* duke@1: * @test duke@1: * @bug 6341023 duke@1: * @summary Tree API: Tree.Kind should have mapping to interface duke@1: */ duke@1: duke@1: import com.sun.source.tree.*; duke@1: duke@1: public class T6341023 { duke@1: public static void main(String... args) { duke@1: boolean ok = true; duke@1: duke@1: for (Tree.Kind k: Tree.Kind.values()) { duke@1: //System.err.println(k + " " + k.asInterface()); duke@1: Class i = k.asInterface(); duke@1: switch (k) { duke@1: case POSTFIX_INCREMENT: duke@1: case POSTFIX_DECREMENT: duke@1: case PREFIX_INCREMENT: duke@1: case PREFIX_DECREMENT: duke@1: case UNARY_PLUS: duke@1: case UNARY_MINUS: duke@1: case BITWISE_COMPLEMENT: duke@1: case LOGICAL_COMPLEMENT: duke@1: ok = ok & verify(k, i, i == UnaryTree.class); duke@1: break; duke@1: duke@1: case MULTIPLY: duke@1: case DIVIDE: duke@1: case REMAINDER: duke@1: case PLUS: duke@1: case MINUS: duke@1: case LEFT_SHIFT: duke@1: case RIGHT_SHIFT: duke@1: case UNSIGNED_RIGHT_SHIFT: duke@1: case LESS_THAN: duke@1: case GREATER_THAN: duke@1: case LESS_THAN_EQUAL: duke@1: case GREATER_THAN_EQUAL: duke@1: case EQUAL_TO: duke@1: case NOT_EQUAL_TO: duke@1: case AND: duke@1: case XOR: duke@1: case OR: duke@1: case CONDITIONAL_AND: duke@1: case CONDITIONAL_OR: duke@1: ok = ok & verify(k, i, i == BinaryTree.class); duke@1: break; duke@1: duke@1: case MULTIPLY_ASSIGNMENT: duke@1: case DIVIDE_ASSIGNMENT: duke@1: case REMAINDER_ASSIGNMENT: duke@1: case PLUS_ASSIGNMENT: duke@1: case MINUS_ASSIGNMENT: duke@1: case LEFT_SHIFT_ASSIGNMENT: duke@1: case RIGHT_SHIFT_ASSIGNMENT: duke@1: case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT: duke@1: case AND_ASSIGNMENT: duke@1: case XOR_ASSIGNMENT: duke@1: case OR_ASSIGNMENT: duke@1: ok = ok & verify(k, i, i == CompoundAssignmentTree.class); duke@1: break; duke@1: duke@1: case INT_LITERAL: duke@1: case LONG_LITERAL: duke@1: case FLOAT_LITERAL: duke@1: case DOUBLE_LITERAL: duke@1: case BOOLEAN_LITERAL: duke@1: case CHAR_LITERAL: duke@1: case STRING_LITERAL: duke@1: case NULL_LITERAL: duke@1: ok = ok & verify(k, i, i == LiteralTree.class); duke@1: break; duke@1: duke@1: case UNBOUNDED_WILDCARD: duke@1: case EXTENDS_WILDCARD: duke@1: case SUPER_WILDCARD: duke@1: ok = ok & verify(k, i, i == WildcardTree.class); duke@1: break; duke@1: duke@1: case OTHER: duke@1: ok = ok & verify(k, i, i == null); duke@1: break; duke@1: duke@1: default: duke@1: String ks = k.toString().replace("_", "") + "tree"; duke@1: String iName = i.getName(); duke@1: String is = iName.substring(iName.lastIndexOf(".") + 1); duke@1: ok = ok & verify(k, i, ks.equalsIgnoreCase(is)); duke@1: } duke@1: } duke@1: duke@1: if (!ok) duke@1: throw new AssertionError("test failed"); duke@1: } duke@1: duke@1: static boolean verify(Tree.Kind k, Class c, boolean b) { duke@1: if (!b) duke@1: System.err.println("error: " + k + " " + c); duke@1: return b; duke@1: } duke@1: }