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

Print this page




  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  */
  23 
  24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
  25 
  26 /*
  27  * @test
  28  * @summary Test population of reference info for field
  29  * @compile -g Driver.java ReferenceInfoUtil.java Fields.java
  30  * @run main Driver Fields
  31  */
  32 public class Fields {
  33 
  34     // field types
  35     @TADescription(annotation = "TA", type = FIELD)
  36     public String fieldAsPrimitive() {
  37         return "@TA int test;";
  38     }
  39 
  40     @TADescription(annotation = "TA", type = FIELD)
  41     public String fieldAsObject() {
  42         return "@TA Object test;";
  43     }
  44 
  45     @TADescriptions({
  46         @TADescription(annotation = "TA", type = FIELD),
  47         @TADescription(annotation = "TB", type = FIELD,
  48                 genericLocation = { 3, 0 }),
  49         @TADescription(annotation = "TC", type = FIELD,
  50                 genericLocation = { 3, 1 }),
  51         @TADescription(annotation = "TD", type = FIELD,
  52                 genericLocation = { 3, 1, 3, 0 })
  53     })


 107         @TADescription(annotation = "TD", type = FIELD,
 108                 genericLocation = { 3, 1, 3, 0 })
 109     })
 110     public String interfacefieldAsParametrized() {
 111         return "interface Test { @TA Map<@TB String, @TC List<@TD String>> test = null; }";
 112     }
 113 
 114 
 115     @TADescriptions({
 116         @TADescription(annotation = "TA", type = FIELD),
 117         @TADescription(annotation = "TB", type = FIELD,
 118                 genericLocation = { 3, 0 }),
 119         @TADescription(annotation = "TC", type = FIELD,
 120                 genericLocation = { 3, 1 }),
 121         @TADescription(annotation = "TD", type = FIELD,
 122                 genericLocation = { 3, 1, 3, 0 })
 123     })
 124     public String staticFieldAsParametrized() {
 125         return "static @TA Map<@TB String, @TC List<@TD String>> test;";
 126     }
 127 
 128 }


  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  */
  23 
  24 import static com.sun.tools.classfile.TypeAnnotation.TargetType.*;
  25 
  26 /*
  27  * @test
  28  * @summary Test population of reference info for field
  29  * @compile -g Driver.java ReferenceInfoUtil.java Fields.java
  30  * @run main Driver Fields
  31  */
  32 public class Fields {

  33     // field types
  34     @TADescription(annotation = "TA", type = FIELD)
  35     public String fieldAsPrimitive() {
  36         return "@TA int test;";
  37     }
  38 
  39     @TADescription(annotation = "TA", type = FIELD)
  40     public String fieldAsObject() {
  41         return "@TA Object test;";
  42     }
  43 
  44     @TADescriptions({
  45         @TADescription(annotation = "TA", type = FIELD),
  46         @TADescription(annotation = "TB", type = FIELD,
  47                 genericLocation = { 3, 0 }),
  48         @TADescription(annotation = "TC", type = FIELD,
  49                 genericLocation = { 3, 1 }),
  50         @TADescription(annotation = "TD", type = FIELD,
  51                 genericLocation = { 3, 1, 3, 0 })
  52     })


 106         @TADescription(annotation = "TD", type = FIELD,
 107                 genericLocation = { 3, 1, 3, 0 })
 108     })
 109     public String interfacefieldAsParametrized() {
 110         return "interface Test { @TA Map<@TB String, @TC List<@TD String>> test = null; }";
 111     }
 112 
 113 
 114     @TADescriptions({
 115         @TADescription(annotation = "TA", type = FIELD),
 116         @TADescription(annotation = "TB", type = FIELD,
 117                 genericLocation = { 3, 0 }),
 118         @TADescription(annotation = "TC", type = FIELD,
 119                 genericLocation = { 3, 1 }),
 120         @TADescription(annotation = "TD", type = FIELD,
 121                 genericLocation = { 3, 1, 3, 0 })
 122     })
 123     public String staticFieldAsParametrized() {
 124         return "static @TA Map<@TB String, @TC List<@TD String>> test;";
 125     }

 126 }