langtools/test/com/sun/javadoc/typeAnnotations/smoke/pkg/TargetTypes.java
changeset 15385 ee1eebe7e210
child 16813 6313f8ad02f8
equal deleted inserted replaced
15384:5a8d00abf076 15385:ee1eebe7e210
       
     1 /*
       
     2  * Copyright (c) 2010 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  */
       
    23 
       
    24 package pkg;
       
    25 
       
    26 import java.lang.annotation.*;
       
    27 import static java.lang.annotation.ElementType.*;
       
    28 import static java.lang.annotation.RetentionPolicy.*;
       
    29 
       
    30 import java.util.*;
       
    31 import java.io.*;
       
    32 
       
    33 /*
       
    34  * @summary compiler accepts all values
       
    35  * @author Mahmood Ali
       
    36  * @author Yuri Gaevsky
       
    37  */
       
    38 
       
    39 @Target({TYPE_USE})
       
    40 @Retention(RetentionPolicy.RUNTIME)
       
    41 @interface A {}
       
    42 
       
    43 @Target({TYPE_USE})
       
    44 @Retention(RetentionPolicy.RUNTIME)
       
    45 @Documented
       
    46 @interface DA {}
       
    47 
       
    48 /** wildcard bound */
       
    49 class T0x1C {
       
    50     void m0x1C(List<? extends @A @DA String> lst) {}
       
    51 }
       
    52 
       
    53 /** wildcard bound generic/array */
       
    54 class T0x1D<T> {
       
    55     void m0x1D(List<? extends @A @DA List<int[]>> lst) {}
       
    56 }
       
    57 
       
    58 /** typecast */
       
    59 class T0x00 {
       
    60     void m0x00(Long l1) {
       
    61         Object l2 = (@A @DA Long) l1;
       
    62     }
       
    63 }
       
    64 
       
    65 /** typecast generic/array */
       
    66 class T0x01<T> {
       
    67     void m0x01(List<T> list) {
       
    68         List<T> l = (List<@A @DA T>) list;
       
    69     }
       
    70 }
       
    71 
       
    72 /** instanceof */
       
    73 class T0x02 {
       
    74     boolean m0x02(String s) {
       
    75         return (s instanceof @A @DA String);
       
    76     }
       
    77 }
       
    78 
       
    79 /** object creation (new) */
       
    80 class T0x04 {
       
    81     void m0x04() {
       
    82         new @A @DA ArrayList<String>();
       
    83     }
       
    84 }
       
    85 
       
    86 /** local variable */
       
    87 class T0x08 {
       
    88     void m0x08() {
       
    89       @A @DA String s = null;
       
    90     }
       
    91 }
       
    92 
       
    93 /** method parameter generic/array */
       
    94 class T0x0D {
       
    95     void m0x0D(HashMap<@A @DA Object, List<@A @DA List<@A @DA Class>>> s1) {}
       
    96 }
       
    97 
       
    98 /** method receiver */
       
    99 class T0x06 {
       
   100     void m0x06(@A @DA T0x06 this) {}
       
   101 }
       
   102 
       
   103 /** method return type generic/array */
       
   104 class T0x0B {
       
   105     Class<@A @DA Object> m0x0B() { return null; }
       
   106 }
       
   107 
       
   108 /** field generic/array */
       
   109 class T0x0F {
       
   110     HashMap<@A @DA Object, @A @DA Object> c1;
       
   111 }
       
   112 
       
   113 /** method type parameter */
       
   114 class T0x20<T, U> {
       
   115     <@A @DA T, @A @DA U> void m0x20() {}
       
   116 }
       
   117 
       
   118 /** class type parameter */
       
   119 class T0x22<@A @DA T, @A @DA U> {
       
   120 }
       
   121 
       
   122 /** class type parameter bound */
       
   123 class T0x10<T extends @A @DA Cloneable> {
       
   124 }
       
   125 
       
   126 class T0x10A<T extends @A @DA Object> {
       
   127 }
       
   128 
       
   129 /** method type parameter bound */
       
   130 class T0x12<T> {
       
   131     <T extends @A @DA Cloneable> void m0x12() {}
       
   132 }
       
   133 
       
   134 /** class type parameter bound generic/array */
       
   135 class T0x11<T extends List<@A @DA T>> {
       
   136 }
       
   137 
       
   138 /** method type parameter bound generic/array */
       
   139 class T0x13 {
       
   140     static <T extends Comparable<@A @DA T>> T m0x13() {
       
   141         return null;
       
   142     }
       
   143 }
       
   144 
       
   145 /** class extends/implements generic/array */
       
   146 class T0x15<T> extends ArrayList<@A @DA T> {
       
   147 }
       
   148 
       
   149 /** type test (instanceof) generic/array */
       
   150 class T0x03<T> {
       
   151     void m0x03(T typeObj, Object obj) {
       
   152         boolean ok = obj instanceof String @A @DA [];
       
   153     }
       
   154 }
       
   155 
       
   156 /** object creation (new) generic/array */
       
   157 class T0x05<T> {
       
   158     void m0x05() {
       
   159         new ArrayList<@A @DA T>();
       
   160     }
       
   161 }
       
   162 
       
   163 /** local variable generic/array */
       
   164 class T0x09<T> {
       
   165     void g() {
       
   166         List<@A @DA String> l = null;
       
   167     }
       
   168 
       
   169     void a() {
       
   170         String @A @DA [] as = null;
       
   171     }
       
   172 }
       
   173 
       
   174 /** type argument in constructor call generic/array */
       
   175 class T0x19 {
       
   176     <T> T0x19() {}
       
   177 
       
   178     void g() {
       
   179        new <List<@A @DA String>> T0x19();
       
   180     }
       
   181 }
       
   182 
       
   183 /** type argument in method call generic/array */
       
   184 class T0x1B<T> {
       
   185     void m0x1B() {
       
   186         Collections.<T @A @DA []>emptyList();
       
   187     }
       
   188 }
       
   189 
       
   190 /** type argument in constructor call */
       
   191 class T0x18<T> {
       
   192     <T> T0x18() {}
       
   193 
       
   194     void m() {
       
   195         new <@A @DA Integer> T0x18();
       
   196     }
       
   197 }
       
   198 
       
   199 /** type argument in method call */
       
   200 class T0x1A<T,U> {
       
   201     public static <T, U> T m() { return null; }
       
   202     static void m0x1A() {
       
   203         T0x1A.<@A @DA Integer, @A @DA Short>m();
       
   204     }
       
   205 }
       
   206 
       
   207 /** class extends/implements */
       
   208 class T0x14 extends @A @DA Thread implements @A @DA Serializable, @A @DA Cloneable {
       
   209 }
       
   210 
       
   211 /** exception type in throws */
       
   212 class T0x16 {
       
   213     void m0x16() throws @A @DA Exception {}
       
   214 }