test/tools/javac/annotations/typeAnnotations/referenceinfos/TypeTests.java

Tue, 24 Dec 2013 09:17:37 -0800

author
ksrini
date
Tue, 24 Dec 2013 09:17:37 -0800
changeset 2227
998b10c43157
parent 1534
bec996065c45
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
Reviewed-by: ksrini
Contributed-by: steve.sides@oracle.com

     1 /*
     2  * Copyright (c) 2009, 2013, 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  */
    24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
    26 /*
    27  * @test
    28  * @summary Test population of reference info for class literals
    29  * @compile -g Driver.java ReferenceInfoUtil.java TypeTests.java
    30  * @run main Driver TypeTests
    31  */
    32 public class TypeTests {
    34     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    35     public String returnObject() {
    36         return "Object returnObject() { return null instanceof @TA String; }";
    37     }
    39     @TADescriptions({
    40         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    41         @TADescription(annotation = "TB", type = INSTANCEOF,
    42                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    43         @TADescription(annotation = "TC", type = INSTANCEOF,
    44                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    45     })
    46     public String returnObjectArray() {
    47         return "Object returnObjectArray() { return null instanceof @TC String @TA [] @TB []; }";
    48     }
    50     // no type test for primitives
    52     @TADescriptions({
    53         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    54         @TADescription(annotation = "TB", type = INSTANCEOF,
    55                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    56         @TADescription(annotation = "TC", type = INSTANCEOF,
    57                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    58     })
    59     public String returnPrimArray() {
    60         return "Object returnPrimArray() { return null instanceof @TC int @TA [] @TB []; }";
    61     }
    63     // no void
    64     // no void array
    66     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    67     public String initObject() {
    68         return "void initObject() { Object a =  null instanceof @TA String; }";
    69     }
    71     @TADescriptions({
    72         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    73         @TADescription(annotation = "TB", type = INSTANCEOF,
    74                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    75         @TADescription(annotation = "TC", type = INSTANCEOF,
    76                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    77     })
    78     public String initObjectArray() {
    79         return "void initObjectArray() { Object a = null instanceof @TC String @TA [] @TB []; }";
    80     }
    82     // no primitive instanceof
    84     @TADescriptions({
    85         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    86         @TADescription(annotation = "TB", type = INSTANCEOF,
    87                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    88         @TADescription(annotation = "TC", type = INSTANCEOF,
    89                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    90     })
    91     public String initPrimArray() {
    92         return "void initPrimArray() { Object a = null instanceof @TC int @TA [] @TB []; }";
    93     }
    95     // no void
    96     // no void array
    98     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    99     public String eqtestObject() {
   100         return "void eqtestObject() { if (true == (null instanceof @TA String)); }";
   101     }
   103     @TADescriptions({
   104         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
   105         @TADescription(annotation = "TB", type = INSTANCEOF,
   106                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
   107         @TADescription(annotation = "TC", type = INSTANCEOF,
   108                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
   109     })
   110     public String eqtestObjectArray() {
   111         return "void eqtestObjectArray() { if (true == (null instanceof @TC String @TA [] @TB [])); }";
   112     }
   114     // no primitives
   116     @TADescriptions({
   117         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
   118         @TADescription(annotation = "TB", type = INSTANCEOF,
   119                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
   120         @TADescription(annotation = "TC", type = INSTANCEOF,
   121                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
   122     })
   123     public String eqtestPrimArray() {
   124         return "void eqtestPrimArray() { if (true == (null instanceof @TC int @TA [] @TB [])); }";
   125     }
   127     // no void
   128     // no void array
   130 }

mercurial