Thu, 07 Jun 2012 20:30:57 -0700
7170079: Adjustments to build-infra makefiles
Reviewed-by: ohair, ohrstrom, ihse, jonas
Contributed-by: jonas <jonas.oreland@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
duke@1 | 1 | /* |
darcy@1054 | 2 | * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. |
duke@1 | 8 | * |
duke@1 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 13 | * accompanied this code). |
duke@1 | 14 | * |
duke@1 | 15 | * You should have received a copy of the GNU General Public License version |
duke@1 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
duke@1 | 22 | */ |
duke@1 | 23 | |
duke@1 | 24 | /* |
duke@1 | 25 | * @test |
duke@1 | 26 | * @bug 6338064 6346249 6340951 6392177 |
duke@1 | 27 | * @summary Tree API: can't determine kind of operator |
duke@1 | 28 | * @author Peter von der Ah\u00e9 |
darcy@1054 | 29 | * @library ../lib |
darcy@1054 | 30 | * @build JavacTestingAbstractProcessor TestOperators |
duke@1 | 31 | * @compile -processor TestOperators -proc:only TestOperators.java |
duke@1 | 32 | */ |
duke@1 | 33 | |
duke@1 | 34 | import java.util.Set; |
duke@1 | 35 | import javax.annotation.processing.*; |
duke@1 | 36 | import javax.lang.model.element.*; |
duke@1 | 37 | import javax.lang.model.util.*; |
duke@1 | 38 | import static javax.tools.Diagnostic.Kind.*; |
duke@1 | 39 | |
duke@1 | 40 | import com.sun.source.tree.*; |
duke@1 | 41 | import com.sun.source.util.Trees; |
duke@1 | 42 | |
duke@1 | 43 | import static com.sun.source.tree.Tree.Kind.*; |
duke@1 | 44 | |
duke@1 | 45 | @interface TestMe { |
duke@1 | 46 | Tree.Kind value(); |
duke@1 | 47 | } |
duke@1 | 48 | |
duke@1 | 49 | @SupportedAnnotationTypes("TestMe") |
darcy@1054 | 50 | public class TestOperators extends JavacTestingAbstractProcessor { |
duke@1 | 51 | |
duke@1 | 52 | @TestMe(POSTFIX_INCREMENT) |
duke@1 | 53 | public int test_POSTFIX_INCREMENT(int i) { |
duke@1 | 54 | return i++; |
duke@1 | 55 | } |
duke@1 | 56 | |
duke@1 | 57 | @TestMe(POSTFIX_DECREMENT) |
duke@1 | 58 | public int test_POSTFIX_DECREMENT(int i) { |
duke@1 | 59 | return i--; |
duke@1 | 60 | } |
duke@1 | 61 | |
duke@1 | 62 | @TestMe(PREFIX_INCREMENT) |
duke@1 | 63 | public int test_PREFIX_INCREMENT(int i) { |
duke@1 | 64 | return ++i; |
duke@1 | 65 | } |
duke@1 | 66 | |
duke@1 | 67 | @TestMe(PREFIX_DECREMENT) |
duke@1 | 68 | public int test_PREFIX_DECREMENT(int i) { |
duke@1 | 69 | return --i; |
duke@1 | 70 | } |
duke@1 | 71 | |
duke@1 | 72 | @TestMe(UNARY_PLUS) |
duke@1 | 73 | public int test_UNARY_PLUS(int i) { |
duke@1 | 74 | return +i; |
duke@1 | 75 | } |
duke@1 | 76 | |
duke@1 | 77 | @TestMe(UNARY_MINUS) |
duke@1 | 78 | public int test_UNARY_MINUS(int i) { |
duke@1 | 79 | return -i; |
duke@1 | 80 | } |
duke@1 | 81 | |
duke@1 | 82 | @TestMe(BITWISE_COMPLEMENT) |
duke@1 | 83 | public int test_BITWISE_COMPLEMENT(int i) { |
duke@1 | 84 | return ~i; |
duke@1 | 85 | } |
duke@1 | 86 | |
duke@1 | 87 | @TestMe(LOGICAL_COMPLEMENT) |
duke@1 | 88 | public boolean test_LOGICAL_COMPLEMENT(boolean b) { |
duke@1 | 89 | return !b; |
duke@1 | 90 | } |
duke@1 | 91 | |
duke@1 | 92 | @TestMe(MULTIPLY) |
duke@1 | 93 | public int test_MULTIPLY(int i, int j) { |
duke@1 | 94 | return i * j; |
duke@1 | 95 | } |
duke@1 | 96 | |
duke@1 | 97 | @TestMe(DIVIDE) |
duke@1 | 98 | public int test_DIVIDE(int i, int j) { |
duke@1 | 99 | return i / j; |
duke@1 | 100 | } |
duke@1 | 101 | |
duke@1 | 102 | @TestMe(REMAINDER) |
duke@1 | 103 | public int test_REMAINDER(int i, int j) { |
duke@1 | 104 | return i % j; |
duke@1 | 105 | } |
duke@1 | 106 | |
duke@1 | 107 | @TestMe(PLUS) |
duke@1 | 108 | public int test_PLUS(int i, int j) { |
duke@1 | 109 | return i + j; |
duke@1 | 110 | } |
duke@1 | 111 | |
duke@1 | 112 | @TestMe(MINUS) |
duke@1 | 113 | public int test_MINUS(int i, int j) { |
duke@1 | 114 | return i - j; |
duke@1 | 115 | } |
duke@1 | 116 | |
duke@1 | 117 | @TestMe(LEFT_SHIFT) |
duke@1 | 118 | public int test_LEFT_SHIFT(int i, int j) { |
duke@1 | 119 | return i << j; |
duke@1 | 120 | } |
duke@1 | 121 | |
duke@1 | 122 | @TestMe(RIGHT_SHIFT) |
duke@1 | 123 | public int test_RIGHT_SHIFT(int i, int j) { |
duke@1 | 124 | return i >> j; |
duke@1 | 125 | } |
duke@1 | 126 | |
duke@1 | 127 | @TestMe(UNSIGNED_RIGHT_SHIFT) |
duke@1 | 128 | public int test_UNSIGNED_RIGHT_SHIFT(int i, int j) { |
duke@1 | 129 | return i >>> j; |
duke@1 | 130 | } |
duke@1 | 131 | |
duke@1 | 132 | @TestMe(LESS_THAN) |
duke@1 | 133 | public boolean test_LESS_THAN(int i, int j) { |
duke@1 | 134 | return i < j; |
duke@1 | 135 | } |
duke@1 | 136 | |
duke@1 | 137 | @TestMe(GREATER_THAN) |
duke@1 | 138 | public boolean test_GREATER_THAN(int i, int j) { |
duke@1 | 139 | return i > j; |
duke@1 | 140 | } |
duke@1 | 141 | |
duke@1 | 142 | @TestMe(LESS_THAN_EQUAL) |
duke@1 | 143 | public boolean test_LESS_THAN_EQUAL(int i, int j) { |
duke@1 | 144 | return i <= j; |
duke@1 | 145 | } |
duke@1 | 146 | |
duke@1 | 147 | @TestMe(GREATER_THAN_EQUAL) |
duke@1 | 148 | public boolean test_GREATER_THAN_EQUAL(int i, int j) { |
duke@1 | 149 | return i >= j; |
duke@1 | 150 | } |
duke@1 | 151 | |
duke@1 | 152 | @TestMe(EQUAL_TO) |
duke@1 | 153 | public boolean test_EQUAL_TO(int i, int j) { |
duke@1 | 154 | return i == j; |
duke@1 | 155 | } |
duke@1 | 156 | |
duke@1 | 157 | @TestMe(NOT_EQUAL_TO) |
duke@1 | 158 | public boolean test_NOT_EQUAL_TO(int i, int j) { |
duke@1 | 159 | return i != j; |
duke@1 | 160 | } |
duke@1 | 161 | |
duke@1 | 162 | @TestMe(AND) |
duke@1 | 163 | public boolean test_AND(boolean a, boolean b) { |
duke@1 | 164 | return a & b; |
duke@1 | 165 | } |
duke@1 | 166 | |
duke@1 | 167 | @TestMe(XOR) |
duke@1 | 168 | public boolean test_XOR(boolean a, boolean b) { |
duke@1 | 169 | return a ^ b; |
duke@1 | 170 | } |
duke@1 | 171 | |
duke@1 | 172 | @TestMe(OR) |
duke@1 | 173 | public boolean test_OR(boolean a, boolean b) { |
duke@1 | 174 | return a | b; |
duke@1 | 175 | } |
duke@1 | 176 | |
duke@1 | 177 | @TestMe(CONDITIONAL_AND) |
duke@1 | 178 | public boolean test_CONDITIONAL_AND(boolean a, boolean b) { |
duke@1 | 179 | return a && b; |
duke@1 | 180 | } |
duke@1 | 181 | |
duke@1 | 182 | @TestMe(CONDITIONAL_OR) |
duke@1 | 183 | public boolean test_CONDITIONAL_OR(boolean a, boolean b) { |
duke@1 | 184 | return a || b; |
duke@1 | 185 | } |
duke@1 | 186 | |
duke@1 | 187 | @TestMe(MULTIPLY_ASSIGNMENT) |
duke@1 | 188 | public int test_MULTIPLY_ASSIGNMENT(int i, int j) { |
duke@1 | 189 | return i *= j; |
duke@1 | 190 | } |
duke@1 | 191 | |
duke@1 | 192 | @TestMe(DIVIDE_ASSIGNMENT) |
duke@1 | 193 | public int test_DIVIDE_ASSIGNMENT(int i, int j) { |
duke@1 | 194 | return i /= j; |
duke@1 | 195 | } |
duke@1 | 196 | |
duke@1 | 197 | @TestMe(REMAINDER_ASSIGNMENT) |
duke@1 | 198 | public int test_REMAINDER_ASSIGNMENT(int i, int j) { |
duke@1 | 199 | return i %= j; |
duke@1 | 200 | } |
duke@1 | 201 | |
duke@1 | 202 | @TestMe(PLUS_ASSIGNMENT) |
duke@1 | 203 | public int test_PLUS_ASSIGNMENT(int i, int j) { |
duke@1 | 204 | return i += j; |
duke@1 | 205 | } |
duke@1 | 206 | |
duke@1 | 207 | @TestMe(MINUS_ASSIGNMENT) |
duke@1 | 208 | public int test_MINUS_ASSIGNMENT(int i, int j) { |
duke@1 | 209 | return i -= j; |
duke@1 | 210 | } |
duke@1 | 211 | |
duke@1 | 212 | @TestMe(LEFT_SHIFT_ASSIGNMENT) |
duke@1 | 213 | public int test_LEFT_SHIFT_ASSIGNMENT(int i, int j) { |
duke@1 | 214 | return i <<= j; |
duke@1 | 215 | } |
duke@1 | 216 | |
duke@1 | 217 | @TestMe(RIGHT_SHIFT_ASSIGNMENT) |
duke@1 | 218 | public int test_RIGHT_SHIFT_ASSIGNMENT(int i, int j) { |
duke@1 | 219 | return i >>= j; |
duke@1 | 220 | } |
duke@1 | 221 | |
duke@1 | 222 | @TestMe(UNSIGNED_RIGHT_SHIFT_ASSIGNMENT) |
duke@1 | 223 | public int test_UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(int i, int j) { |
duke@1 | 224 | return i >>>= j; |
duke@1 | 225 | } |
duke@1 | 226 | |
duke@1 | 227 | @TestMe(AND_ASSIGNMENT) |
duke@1 | 228 | public boolean test_AND_ASSIGNMENT(boolean a, boolean b) { |
duke@1 | 229 | return a &= b; |
duke@1 | 230 | } |
duke@1 | 231 | |
duke@1 | 232 | @TestMe(XOR_ASSIGNMENT) |
duke@1 | 233 | public boolean test_XOR_ASSIGNMENT(boolean a, boolean b) { |
duke@1 | 234 | return a ^= b; |
duke@1 | 235 | } |
duke@1 | 236 | |
duke@1 | 237 | @TestMe(OR_ASSIGNMENT) |
duke@1 | 238 | public boolean test_OR_ASSIGNMENT(boolean a, boolean b) { |
duke@1 | 239 | return a |= b; |
duke@1 | 240 | } |
duke@1 | 241 | |
duke@1 | 242 | @TestMe(INT_LITERAL) |
duke@1 | 243 | public Object test_INT_LITERAL() { |
duke@1 | 244 | return 0; |
duke@1 | 245 | } |
duke@1 | 246 | |
duke@1 | 247 | @TestMe(LONG_LITERAL) |
duke@1 | 248 | public Object test_LONG_LITERAL() { |
duke@1 | 249 | return 0L; |
duke@1 | 250 | } |
duke@1 | 251 | |
duke@1 | 252 | @TestMe(FLOAT_LITERAL) |
duke@1 | 253 | public Object test_FLOAT_LITERAL() { |
duke@1 | 254 | return 0.0F; |
duke@1 | 255 | } |
duke@1 | 256 | |
duke@1 | 257 | @TestMe(DOUBLE_LITERAL) |
duke@1 | 258 | public Object test_DOUBLE_LITERAL() { |
duke@1 | 259 | return 0.0; |
duke@1 | 260 | } |
duke@1 | 261 | |
duke@1 | 262 | @TestMe(BOOLEAN_LITERAL) |
duke@1 | 263 | public Object test_BOOLEAN_LITERAL() { |
duke@1 | 264 | return true; |
duke@1 | 265 | } |
duke@1 | 266 | |
duke@1 | 267 | @TestMe(CHAR_LITERAL) |
duke@1 | 268 | public Object test_CHAR_LITERAL() { |
duke@1 | 269 | return 'a'; |
duke@1 | 270 | } |
duke@1 | 271 | |
duke@1 | 272 | @TestMe(STRING_LITERAL) |
duke@1 | 273 | public Object test_STRING_LITERAL() { |
duke@1 | 274 | return "a"; |
duke@1 | 275 | } |
duke@1 | 276 | |
duke@1 | 277 | @TestMe(NULL_LITERAL) |
duke@1 | 278 | public Object test_NULL_LITERAL() { |
duke@1 | 279 | return null; |
duke@1 | 280 | } |
duke@1 | 281 | |
duke@1 | 282 | @TestMe(UNBOUNDED_WILDCARD) |
duke@1 | 283 | public Set<?> test_UNBOUNDED_WILDCARD() { |
duke@1 | 284 | return null; |
duke@1 | 285 | } |
duke@1 | 286 | |
duke@1 | 287 | @TestMe(EXTENDS_WILDCARD) |
duke@1 | 288 | public Set<? extends Number> test_EXTENDS_WILDCARD() { |
duke@1 | 289 | return null; |
duke@1 | 290 | } |
duke@1 | 291 | |
duke@1 | 292 | @TestMe(SUPER_WILDCARD) |
duke@1 | 293 | public Set<? super Number> test_SUPER_WILDCARD() { |
duke@1 | 294 | return null; |
duke@1 | 295 | } |
duke@1 | 296 | |
duke@1 | 297 | public boolean process(Set<? extends TypeElement> annotations, |
duke@1 | 298 | RoundEnvironment roundEnvironment) |
duke@1 | 299 | { |
duke@1 | 300 | final Trees trees = Trees.instance(processingEnv); |
duke@1 | 301 | final Messager log = processingEnv.getMessager(); |
duke@1 | 302 | final Elements elements = processingEnv.getElementUtils(); |
darcy@1054 | 303 | class Scan extends ElementScanner<Void,Void> { |
duke@1 | 304 | @Override |
duke@1 | 305 | public Void visitExecutable(ExecutableElement e, Void p) { |
duke@1 | 306 | Object debug = e; // info for exception handler |
duke@1 | 307 | try { |
duke@1 | 308 | TestMe info = e.getAnnotation(TestMe.class); |
duke@1 | 309 | if (info == null) |
duke@1 | 310 | return null; |
duke@1 | 311 | |
duke@1 | 312 | Tree.Kind kind = info.value(); |
duke@1 | 313 | MethodTree node = trees.getTree(e); |
duke@1 | 314 | debug = node; |
duke@1 | 315 | Tree testNode; |
duke@1 | 316 | switch (kind) { |
duke@1 | 317 | case UNBOUNDED_WILDCARD: |
duke@1 | 318 | case EXTENDS_WILDCARD: |
duke@1 | 319 | case SUPER_WILDCARD: |
duke@1 | 320 | ParameterizedTypeTree typeTree; |
duke@1 | 321 | typeTree = (ParameterizedTypeTree) node.getReturnType(); |
duke@1 | 322 | testNode = typeTree.getTypeArguments().get(0); |
duke@1 | 323 | break; |
duke@1 | 324 | default: |
duke@1 | 325 | ReturnTree returnNode; |
duke@1 | 326 | returnNode = (ReturnTree) node.getBody().getStatements().get(0); |
duke@1 | 327 | testNode = returnNode.getExpression(); |
duke@1 | 328 | } |
duke@1 | 329 | if (testNode.getKind() != kind) { |
duke@1 | 330 | log.printMessage(ERROR, testNode.getKind() + " != " + kind, e); |
duke@1 | 331 | throw new AssertionError(testNode); |
duke@1 | 332 | } |
duke@1 | 333 | System.err.format("OK: %32s %s%n", kind, testNode); |
duke@1 | 334 | } catch (Error ex) { |
duke@1 | 335 | System.err.println("Error while looking at " + debug); |
duke@1 | 336 | throw ex; |
duke@1 | 337 | } |
duke@1 | 338 | return null; |
duke@1 | 339 | } |
duke@1 | 340 | } |
duke@1 | 341 | Scan scan = new Scan(); |
duke@1 | 342 | for (Element e : roundEnvironment.getRootElements()) { |
duke@1 | 343 | scan.scan(e); |
duke@1 | 344 | } |
duke@1 | 345 | return true; |
duke@1 | 346 | } |
duke@1 | 347 | } |