langtools/test/tools/javac/api/TestOperators.java
author darcy
Tue, 05 Jul 2011 16:37:24 -0700
changeset 10192 378321489bea
parent 7681 1f0819a3341f
child 30730 d3ce7619db2c
permissions -rw-r--r--
7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8 Reviewed-by: jjg, mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
10192
378321489bea 7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8
darcy
parents: 7681
diff changeset
     2
 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
10
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
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * questions.
10
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     6338064 6346249 6340951 6392177
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary Tree API: can't determine kind of operator
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 * @author  Peter von der Ah\u00e9
10192
378321489bea 7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8
darcy
parents: 7681
diff changeset
    29
 * @library ../lib
378321489bea 7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8
darcy
parents: 7681
diff changeset
    30
 * @build JavacTestingAbstractProcessor TestOperators
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 * @compile -processor TestOperators -proc:only TestOperators.java
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
import javax.annotation.processing.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import javax.lang.model.element.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import javax.lang.model.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import static javax.tools.Diagnostic.Kind.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
import com.sun.source.tree.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
import com.sun.source.util.Trees;
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
import static com.sun.source.tree.Tree.Kind.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
@interface TestMe {
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    Tree.Kind value();
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
}
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
@SupportedAnnotationTypes("TestMe")
10192
378321489bea 7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8
darcy
parents: 7681
diff changeset
    50
public class TestOperators extends JavacTestingAbstractProcessor {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    @TestMe(POSTFIX_INCREMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    public int test_POSTFIX_INCREMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
        return i++;
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    @TestMe(POSTFIX_DECREMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    public int test_POSTFIX_DECREMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
        return i--;
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    @TestMe(PREFIX_INCREMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    public int test_PREFIX_INCREMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
        return ++i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    @TestMe(PREFIX_DECREMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    public int test_PREFIX_DECREMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        return --i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    @TestMe(UNARY_PLUS)
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    public int test_UNARY_PLUS(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        return +i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    @TestMe(UNARY_MINUS)
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    public int test_UNARY_MINUS(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        return -i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    @TestMe(BITWISE_COMPLEMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public int test_BITWISE_COMPLEMENT(int i) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        return ~i;
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    @TestMe(LOGICAL_COMPLEMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public boolean test_LOGICAL_COMPLEMENT(boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
        return !b;
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    @TestMe(MULTIPLY)
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    public int test_MULTIPLY(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        return i * j;
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    @TestMe(DIVIDE)
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    public int test_DIVIDE(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        return i / j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    @TestMe(REMAINDER)
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public int test_REMAINDER(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        return i % j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    @TestMe(PLUS)
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    public int test_PLUS(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        return i + j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    @TestMe(MINUS)
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    public int test_MINUS(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        return i - j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    @TestMe(LEFT_SHIFT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    public int test_LEFT_SHIFT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        return i << j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    @TestMe(RIGHT_SHIFT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    public int test_RIGHT_SHIFT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        return i >> j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    @TestMe(UNSIGNED_RIGHT_SHIFT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    public int test_UNSIGNED_RIGHT_SHIFT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        return i >>> j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    @TestMe(LESS_THAN)
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    public boolean test_LESS_THAN(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        return i < j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    @TestMe(GREATER_THAN)
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    public boolean test_GREATER_THAN(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        return i > j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    @TestMe(LESS_THAN_EQUAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    public boolean test_LESS_THAN_EQUAL(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        return i <= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    @TestMe(GREATER_THAN_EQUAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    public boolean test_GREATER_THAN_EQUAL(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        return i >= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    @TestMe(EQUAL_TO)
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    public boolean test_EQUAL_TO(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        return i == j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    @TestMe(NOT_EQUAL_TO)
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    public boolean test_NOT_EQUAL_TO(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        return i != j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    @TestMe(AND)
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    public boolean test_AND(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        return a & b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    @TestMe(XOR)
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    public boolean test_XOR(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        return a ^ b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    @TestMe(OR)
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    public boolean test_OR(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        return a | b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    @TestMe(CONDITIONAL_AND)
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    public boolean test_CONDITIONAL_AND(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        return a && b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    @TestMe(CONDITIONAL_OR)
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    public boolean test_CONDITIONAL_OR(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
        return a || b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
    @TestMe(MULTIPLY_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    public int test_MULTIPLY_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        return i *= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    @TestMe(DIVIDE_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    public int test_DIVIDE_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        return i /= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    @TestMe(REMAINDER_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    public int test_REMAINDER_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        return i %= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    @TestMe(PLUS_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    public int test_PLUS_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        return i += j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    @TestMe(MINUS_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    public int test_MINUS_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        return i -= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    @TestMe(LEFT_SHIFT_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    public int test_LEFT_SHIFT_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        return i <<= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
    @TestMe(RIGHT_SHIFT_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    public int test_RIGHT_SHIFT_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        return i >>= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    @TestMe(UNSIGNED_RIGHT_SHIFT_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    public int test_UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(int i, int j) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        return i >>>= j;
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    @TestMe(AND_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
    public boolean test_AND_ASSIGNMENT(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        return a &= b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    @TestMe(XOR_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    public boolean test_XOR_ASSIGNMENT(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
        return a ^= b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    @TestMe(OR_ASSIGNMENT)
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    public boolean test_OR_ASSIGNMENT(boolean a, boolean b) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        return a |= b;
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    @TestMe(INT_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    public Object test_INT_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        return 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    @TestMe(LONG_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    public Object test_LONG_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        return 0L;
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    @TestMe(FLOAT_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    public Object test_FLOAT_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        return 0.0F;
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
    @TestMe(DOUBLE_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    public Object test_DOUBLE_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
        return 0.0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    @TestMe(BOOLEAN_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
    public Object test_BOOLEAN_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
    @TestMe(CHAR_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    public Object test_CHAR_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        return 'a';
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    @TestMe(STRING_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    public Object test_STRING_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        return "a";
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    @TestMe(NULL_LITERAL)
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
    public Object test_NULL_LITERAL() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    @TestMe(UNBOUNDED_WILDCARD)
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    public Set<?> test_UNBOUNDED_WILDCARD() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
    @TestMe(EXTENDS_WILDCARD)
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
    public Set<? extends Number> test_EXTENDS_WILDCARD() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    @TestMe(SUPER_WILDCARD)
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
    public Set<? super Number> test_SUPER_WILDCARD() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    public boolean process(Set<? extends TypeElement> annotations,
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
                           RoundEnvironment roundEnvironment)
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
    {
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        final Trees trees = Trees.instance(processingEnv);
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        final Messager log = processingEnv.getMessager();
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        final Elements elements = processingEnv.getElementUtils();
10192
378321489bea 7025809: Provided new utility visitors supporting SourceVersion.RELEASE_8
darcy
parents: 7681
diff changeset
   303
        class Scan extends ElementScanner<Void,Void> {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
            @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
            public Void visitExecutable(ExecutableElement e, Void p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
                Object debug = e; // info for exception handler
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
                try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
                    TestMe info = e.getAnnotation(TestMe.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
                    if (info == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
                        return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
                    Tree.Kind kind = info.value();
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
                    MethodTree node = trees.getTree(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
                    debug = node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
                    Tree testNode;
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
                    switch (kind) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
                    case UNBOUNDED_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
                    case EXTENDS_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
                    case SUPER_WILDCARD:
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
                        ParameterizedTypeTree typeTree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
                        typeTree = (ParameterizedTypeTree) node.getReturnType();
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
                        testNode = typeTree.getTypeArguments().get(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
                        break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
                    default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
                        ReturnTree returnNode;
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
                        returnNode = (ReturnTree) node.getBody().getStatements().get(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
                        testNode = returnNode.getExpression();
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
                    if (testNode.getKind() != kind) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
                        log.printMessage(ERROR, testNode.getKind() + " != " + kind, e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
                        throw new AssertionError(testNode);
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
                    System.err.format("OK: %32s %s%n", kind, testNode);
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
                } catch (Error ex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
                    System.err.println("Error while looking at " + debug);
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
                    throw ex;
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
                return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
        Scan scan = new Scan();
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
        for (Element e : roundEnvironment.getRootElements()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
            scan.scan(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
}