langtools/test/tools/javac/T6341023.java
author jjg
Fri, 09 Apr 2010 15:39:39 -0700
changeset 5319 63dc7f367a37
parent 10 06bc494ca11e
child 5520 86e4b9a9da40
permissions -rw-r--r--
6942649: add hidden option to identify location and version of javac classes Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
 * @test
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
 * @bug 6341023
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary Tree API: Tree.Kind should have mapping to interface
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.source.tree.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
public class T6341023 {
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
    public static void main(String... args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
        boolean ok = true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
        for (Tree.Kind k: Tree.Kind.values()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
            //System.err.println(k + " " + k.asInterface());
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
            Class<? extends Tree> i = k.asInterface();
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
            switch (k) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
            case POSTFIX_INCREMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
            case POSTFIX_DECREMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
            case PREFIX_INCREMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
            case PREFIX_DECREMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
            case UNARY_PLUS:
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
            case UNARY_MINUS:
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
            case BITWISE_COMPLEMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
            case LOGICAL_COMPLEMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
                ok = ok & verify(k, i, i == UnaryTree.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
            case MULTIPLY:
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
            case DIVIDE:
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
            case REMAINDER:
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
            case PLUS:
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
            case MINUS:
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
            case LEFT_SHIFT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
            case RIGHT_SHIFT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
            case UNSIGNED_RIGHT_SHIFT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
            case LESS_THAN:
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
            case GREATER_THAN:
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
            case LESS_THAN_EQUAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
            case GREATER_THAN_EQUAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
            case EQUAL_TO:
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
            case NOT_EQUAL_TO:
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
            case AND:
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
            case XOR:
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
            case OR:
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
            case CONDITIONAL_AND:
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
            case CONDITIONAL_OR:
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
                ok = ok & verify(k, i, i == BinaryTree.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
            case MULTIPLY_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
            case DIVIDE_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
            case REMAINDER_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
            case PLUS_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
            case MINUS_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            case LEFT_SHIFT_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
            case RIGHT_SHIFT_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
            case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
            case AND_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            case XOR_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
            case OR_ASSIGNMENT:
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
                ok = ok & verify(k, i, i == CompoundAssignmentTree.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
            case INT_LITERAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
            case LONG_LITERAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
            case FLOAT_LITERAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
            case DOUBLE_LITERAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
            case BOOLEAN_LITERAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            case CHAR_LITERAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
            case STRING_LITERAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
            case NULL_LITERAL:
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
                ok = ok & verify(k, i, i == LiteralTree.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            case UNBOUNDED_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
            case EXTENDS_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
            case SUPER_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
                ok = ok & verify(k, i, i == WildcardTree.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
            case OTHER:
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                ok = ok & verify(k, i, i == null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
            default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
                String ks = k.toString().replace("_", "") + "tree";
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
                String iName = i.getName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
                String is = iName.substring(iName.lastIndexOf(".") + 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
                ok = ok & verify(k, i, ks.equalsIgnoreCase(is));
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        if (!ok)
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
            throw new AssertionError("test failed");
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    static boolean verify(Tree.Kind k, Class<?> c, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        if (!b)
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
            System.err.println("error: " + k + " " + c);
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        return b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
}