langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/TypeTests.java
changeset 24896 986d876a9121
parent 22448 a85fbad9d687
child 30730 d3ce7619db2c
equal deleted inserted replaced
24895:dd091d389fbf 24896:986d876a9121
    23 
    23 
    24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
    24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
    25 
    25 
    26 /*
    26 /*
    27  * @test
    27  * @test
       
    28  * @bug 8042451
    28  * @summary Test population of reference info for class literals
    29  * @summary Test population of reference info for class literals
    29  * @compile -g Driver.java ReferenceInfoUtil.java TypeTests.java
    30  * @compile -g Driver.java ReferenceInfoUtil.java TypeTests.java
    30  * @run main Driver TypeTests
    31  * @run main Driver TypeTests
    31  */
    32  */
    32 public class TypeTests {
    33 public class TypeTests {
    34     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    35     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    35     public String returnObject() {
    36     public String returnObject() {
    36         return "Object returnObject() { return null instanceof @TA String; }";
    37         return "Object returnObject() { return null instanceof @TA String; }";
    37     }
    38     }
    38 
    39 
    39     @TADescriptions({
    40     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    40         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    41     @TADescription(annotation = "TB", type = INSTANCEOF,
    41         @TADescription(annotation = "TB", type = INSTANCEOF,
    42             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    42                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    43     @TADescription(annotation = "TC", type = INSTANCEOF,
    43         @TADescription(annotation = "TC", type = INSTANCEOF,
    44             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    44                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
    45     })
       
    46     public String returnObjectArray() {
    45     public String returnObjectArray() {
    47         return "Object returnObjectArray() { return null instanceof @TC String @TA [] @TB []; }";
    46         return "Object returnObjectArray() { return null instanceof @TC String @TA [] @TB []; }";
    48     }
    47     }
    49 
    48 
    50     // no type test for primitives
    49     // no type test for primitives
    51 
    50 
    52     @TADescriptions({
    51     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    53         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    52     @TADescription(annotation = "TB", type = INSTANCEOF,
    54         @TADescription(annotation = "TB", type = INSTANCEOF,
    53             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    55                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    54     @TADescription(annotation = "TC", type = INSTANCEOF,
    56         @TADescription(annotation = "TC", type = INSTANCEOF,
    55             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    57                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
    58     })
       
    59     public String returnPrimArray() {
    56     public String returnPrimArray() {
    60         return "Object returnPrimArray() { return null instanceof @TC int @TA [] @TB []; }";
    57         return "Object returnPrimArray() { return null instanceof @TC int @TA [] @TB []; }";
    61     }
    58     }
    62 
    59 
    63     // no void
    60     // no void
    66     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    63     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    67     public String initObject() {
    64     public String initObject() {
    68         return "void initObject() { Object a =  null instanceof @TA String; }";
    65         return "void initObject() { Object a =  null instanceof @TA String; }";
    69     }
    66     }
    70 
    67 
    71     @TADescriptions({
    68     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    72         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    69     @TADescription(annotation = "TB", type = INSTANCEOF,
    73         @TADescription(annotation = "TB", type = INSTANCEOF,
    70             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    74                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    71     @TADescription(annotation = "TC", type = INSTANCEOF,
    75         @TADescription(annotation = "TC", type = INSTANCEOF,
    72             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    76                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
    77     })
       
    78     public String initObjectArray() {
    73     public String initObjectArray() {
    79         return "void initObjectArray() { Object a = null instanceof @TC String @TA [] @TB []; }";
    74         return "void initObjectArray() { Object a = null instanceof @TC String @TA [] @TB []; }";
    80     }
    75     }
    81 
    76 
    82     // no primitive instanceof
    77     // no primitive instanceof
    83 
    78 
    84     @TADescriptions({
    79     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    85         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    80     @TADescription(annotation = "TB", type = INSTANCEOF,
    86         @TADescription(annotation = "TB", type = INSTANCEOF,
    81             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    87                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    82     @TADescription(annotation = "TC", type = INSTANCEOF,
    88         @TADescription(annotation = "TC", type = INSTANCEOF,
    83             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
    89                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
    90     })
       
    91     public String initPrimArray() {
    84     public String initPrimArray() {
    92         return "void initPrimArray() { Object a = null instanceof @TC int @TA [] @TB []; }";
    85         return "void initPrimArray() { Object a = null instanceof @TC int @TA [] @TB []; }";
    93     }
    86     }
    94 
    87 
    95     // no void
    88     // no void
    98     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    91     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
    99     public String eqtestObject() {
    92     public String eqtestObject() {
   100         return "void eqtestObject() { if (true == (null instanceof @TA String)); }";
    93         return "void eqtestObject() { if (true == (null instanceof @TA String)); }";
   101     }
    94     }
   102 
    95 
   103     @TADescriptions({
    96     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
   104         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
    97     @TADescription(annotation = "TB", type = INSTANCEOF,
   105         @TADescription(annotation = "TB", type = INSTANCEOF,
    98             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
   106                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
    99     @TADescription(annotation = "TC", type = INSTANCEOF,
   107         @TADescription(annotation = "TC", type = INSTANCEOF,
   100             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
   108                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   109     })
       
   110     public String eqtestObjectArray() {
   101     public String eqtestObjectArray() {
   111         return "void eqtestObjectArray() { if (true == (null instanceof @TC String @TA [] @TB [])); }";
   102         return "void eqtestObjectArray() { if (true == (null instanceof @TC String @TA [] @TB [])); }";
   112     }
   103     }
   113 
   104 
   114     // no primitives
   105     // no primitives
   115 
   106 
   116     @TADescriptions({
   107     @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
   117         @TADescription(annotation = "TA", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE),
   108     @TADescription(annotation = "TB", type = INSTANCEOF,
   118         @TADescription(annotation = "TB", type = INSTANCEOF,
   109             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
   119                 genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE),
   110     @TADescription(annotation = "TC", type = INSTANCEOF,
   120         @TADescription(annotation = "TC", type = INSTANCEOF,
   111             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
   121                 genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   122     })
       
   123     public String eqtestPrimArray() {
   112     public String eqtestPrimArray() {
   124         return "void eqtestPrimArray() { if (true == (null instanceof @TC int @TA [] @TB [])); }";
   113         return "void eqtestPrimArray() { if (true == (null instanceof @TC int @TA [] @TB [])); }";
   125     }
   114     }
   126 
   115 
   127     // no void
   116     // no void
   128     // no void array
   117     // no void array
   129 
   118 
       
   119     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   120     public String returnObjectRepeatableAnnotation() {
       
   121         return "Object returnObject() { return null instanceof @RTA @RTA String; }";
       
   122     }
       
   123 
       
   124     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   125     @TADescription(annotation = "RTBs", type = INSTANCEOF,
       
   126             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   127     @TADescription(annotation = "RTCs", type = INSTANCEOF,
       
   128             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   129     public String returnObjectArrayRepeatableAnnotation() {
       
   130         return "Object returnObjectArray() { return null instanceof @RTC @RTC String @RTA @RTA [] @RTB @RTB []; }";
       
   131     }
       
   132 
       
   133     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   134     @TADescription(annotation = "RTBs", type = INSTANCEOF,
       
   135             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   136     @TADescription(annotation = "RTCs", type = INSTANCEOF,
       
   137             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   138     public String returnPrimArrayRepeatableAnnotation() {
       
   139         return "Object returnPrimArrayRepeatableAnnotation() { return null instanceof @RTC @RTC int @RTA @RTA [] @RTB @RTB []; }";
       
   140     }
       
   141 
       
   142     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   143     public String initObjectRepeatableAnnotation() {
       
   144         return "void initObject() { Object a =  null instanceof @RTA @RTA String; }";
       
   145     }
       
   146 
       
   147     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   148     @TADescription(annotation = "RTBs", type = INSTANCEOF,
       
   149             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   150     @TADescription(annotation = "RTCs", type = INSTANCEOF,
       
   151             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   152     public String initObjectArrayRepeatableAnnotation() {
       
   153         return "void initObjectArray() { Object a = null instanceof @RTC @RTC String @RTA @RTA [] @RTB @RTB []; }";
       
   154     }
       
   155 
       
   156     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   157     @TADescription(annotation = "RTBs", type = INSTANCEOF,
       
   158             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   159     @TADescription(annotation = "RTCs", type = INSTANCEOF,
       
   160             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   161     public String initPrimArrayRepeatableAnnotation() {
       
   162         return "void initPrimArray() { Object a = null instanceof @RTC @RTC int @RTA @RTA [] @RTB @RTB []; }";
       
   163     }
       
   164 
       
   165     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   166     public String eqtestObjectRepeatableAnnotation() {
       
   167         return "void eqtestObject() { if (true == (null instanceof @RTA @RTA String)); }";
       
   168     }
       
   169 
       
   170     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   171     @TADescription(annotation = "RTBs", type = INSTANCEOF,
       
   172             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   173     @TADescription(annotation = "RTCs", type = INSTANCEOF,
       
   174             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   175     public String eqtestObjectArrayRepeatableAnnotation() {
       
   176         return "void eqtestObjectArray() { if (true == (null instanceof @RTC @RTC String @RTA @RTA [] @RTB @RTB [])); }";
       
   177     }
       
   178 
       
   179     @TADescription(annotation = "RTAs", type = INSTANCEOF, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   180     @TADescription(annotation = "RTBs", type = INSTANCEOF,
       
   181             genericLocation = { 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   182     @TADescription(annotation = "RTCs", type = INSTANCEOF,
       
   183             genericLocation = { 0, 0, 0, 0 }, offset = ReferenceInfoUtil.IGNORE_VALUE)
       
   184     public String eqtestPrimArrayRepeatableAnnotation() {
       
   185         return "void eqtestPrimArray() { if (true == (null instanceof @RTC @RTC int @RTA @RTA [] @RTB @RTB [])); }";
       
   186     }
   130 }
   187 }