langtools/test/tools/javac/classfiles/attributes/Signature/FieldTest.java
changeset 29637 c03745b71c70
child 30730 d3ce7619db2c
equal deleted inserted replaced
29559:47544495db2d 29637:c03745b71c70
       
     1 /*
       
     2  * Copyright (c) 2015, 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 /*
       
    25  * @test
       
    26  * @bug 8049238
       
    27  * @summary Checks Signature attribute for fields.
       
    28  * @library /tools/lib /tools/javac/lib ../lib
       
    29  * @build TestBase TestResult InMemoryFileManager ToolBox
       
    30  * @build FieldTest Driver ExpectedSignature ExpectedSignatureContainer
       
    31  * @run main Driver FieldTest
       
    32  */
       
    33 
       
    34 import java.util.Comparator;
       
    35 import java.util.List;
       
    36 import java.util.Map;
       
    37 
       
    38 @ExpectedSignature(descriptor = "FieldTest", signature = "<T:Ljava/lang/Object;>Ljava/lang/Object;")
       
    39 public class FieldTest<T> {
       
    40 
       
    41     @ExpectedSignature(descriptor = "typeInList", signature = "Ljava/util/List<TT;>;")
       
    42     List<T> typeInList;
       
    43 
       
    44     @ExpectedSignature(descriptor = "boundsType", signature = "Ljava/util/List<Ljava/util/Map<+TT;-TT;>;>;")
       
    45     List<Map<? extends T, ? super T>> boundsType;
       
    46 
       
    47     @ExpectedSignature(descriptor = "type", signature = "TT;")
       
    48     T type;
       
    49 
       
    50     @ExpectedSignature(descriptor = "typeInArray", signature = "[TT;")
       
    51     T[] typeInArray;
       
    52 
       
    53     @ExpectedSignature(descriptor = "byteArrayInList", signature = "Ljava/util/List<[B>;")
       
    54     List<byte[]> byteArrayInList;
       
    55 
       
    56     @ExpectedSignature(descriptor = "shortArrayInList", signature = "Ljava/util/List<[S>;")
       
    57     List<short[]> shortArrayInList;
       
    58 
       
    59     @ExpectedSignature(descriptor = "intArrayInList", signature = "Ljava/util/List<[I>;")
       
    60     List<int[]> intArrayInList;
       
    61 
       
    62     @ExpectedSignature(descriptor = "longArrayInList", signature = "Ljava/util/List<[J>;")
       
    63     List<long[]> longArrayInList;
       
    64 
       
    65     @ExpectedSignature(descriptor = "charArrayInList", signature = "Ljava/util/List<[C>;")
       
    66     List<char[]> charArrayInList;
       
    67 
       
    68     @ExpectedSignature(descriptor = "booleanArrayInList", signature = "Ljava/util/List<[Z>;")
       
    69     List<boolean[]> booleanArrayInList;
       
    70 
       
    71     @ExpectedSignature(descriptor = "floatArrayInList", signature = "Ljava/util/List<[F>;")
       
    72     List<float[]> floatArrayInList;
       
    73 
       
    74     @ExpectedSignature(descriptor = "doubleArrayInList", signature = "Ljava/util/List<[D>;")
       
    75     List<double[]> doubleArrayInList;
       
    76 
       
    77     @ExpectedSignature(descriptor = "integerInList", signature = "Ljava/util/List<Ljava/lang/Integer;>;")
       
    78     List<Integer> integerInList;
       
    79 
       
    80     @ExpectedSignature(descriptor = "typeInMultiArray", signature = "[[TT;")
       
    81     T[][] typeInMultiArray;
       
    82 
       
    83     @ExpectedSignature(descriptor = "arrayOfClasses", signature = "[Ljava/util/List<TT;>;")
       
    84     List<T>[] arrayOfClasses;
       
    85 
       
    86     @ExpectedSignature(descriptor = "extendsWildCard", signature = "Ljava/util/List<+TT;>;")
       
    87     List<? extends T> extendsWildCard;
       
    88 
       
    89     @ExpectedSignature(descriptor = "superWildCard", signature = "Ljava/util/Comparator<-TT;>;")
       
    90     Comparator<? super T> superWildCard;
       
    91 
       
    92     @ExpectedSignature(descriptor = "extendsSuperWildCard",
       
    93             signature = "Ljava/util/List<+Ljava/util/Comparator<-TT;>;>;")
       
    94     List<? extends Comparator<? super T>> extendsSuperWildCard;
       
    95 
       
    96     @ExpectedSignature(descriptor = "wildCard", signature = "Ljava/util/Comparator<*>;")
       
    97     Comparator<?> wildCard;
       
    98 
       
    99     @ExpectedSignature(descriptor = "boundsBooleanArray", signature = "Ljava/util/Map<+[Z-[Z>;")
       
   100     Map<? extends boolean[], ? super boolean[]> boundsBooleanArray;
       
   101 
       
   102     @ExpectedSignature(descriptor = "boundsByteArray", signature = "Ljava/util/Map<+[B-[B>;")
       
   103     Map<? extends byte[], ? super byte[]> boundsByteArray;
       
   104 
       
   105     @ExpectedSignature(descriptor = "boundsShortArray", signature = "Ljava/util/Map<+[S-[S>;")
       
   106     Map<? extends short[], ? super short[]> boundsShortArray;
       
   107 
       
   108     @ExpectedSignature(descriptor = "boundsIntArray", signature = "Ljava/util/Map<+[I-[I>;")
       
   109     Map<? extends int[], ? super int[]> boundsIntArray;
       
   110 
       
   111     @ExpectedSignature(descriptor = "boundsLongArray", signature = "Ljava/util/Map<+[J-[J>;")
       
   112     Map<? extends long[], ? super long[]> boundsLongArray;
       
   113 
       
   114     @ExpectedSignature(descriptor = "boundsCharArray", signature = "Ljava/util/Map<+[C-[C>;")
       
   115     Map<? extends char[], ? super char[]> boundsCharArray;
       
   116 
       
   117     @ExpectedSignature(descriptor = "boundsFloatArray", signature = "Ljava/util/Map<+[F-[F>;")
       
   118     Map<? extends float[], ? super float[]> boundsFloatArray;
       
   119 
       
   120     @ExpectedSignature(descriptor = "boundsDoubleArray", signature = "Ljava/util/Map<+[D-[D>;")
       
   121     Map<? extends double[], ? super double[]> boundsDoubleArray;
       
   122 
       
   123     @ExpectedSignature(descriptor = "boundsObjectArray",
       
   124             signature = "Ljava/util/Map<+[Ljava/lang/Object;-[Ljava/lang/Object;>;")
       
   125     Map<? extends Object[], ? super Object[]> boundsObjectArray;
       
   126 
       
   127     boolean booleanNoSignatureAttribute;
       
   128     byte byteNoSignatureAttribute;
       
   129     char charNoSignatureAttribute;
       
   130     short shortNoSignatureAttribute;
       
   131     int intNoSignatureAttribute;
       
   132     long longNoSignatureAttribute;
       
   133     float floatNoSignatureAttribute;
       
   134     double doubleNoSignatureAttribute;
       
   135 
       
   136     List listNoSignatureAttribute;
       
   137 
       
   138     @ExpectedSignature(descriptor = "staticByteArrayInList", signature = "Ljava/util/List<[B>;")
       
   139     static List<byte[]> staticByteArrayInList;
       
   140 
       
   141     @ExpectedSignature(descriptor = "staticShortArrayInList", signature = "Ljava/util/List<[S>;")
       
   142     static List<short[]> staticShortArrayInList;
       
   143 
       
   144     @ExpectedSignature(descriptor = "staticIntArrayInList", signature = "Ljava/util/List<[I>;")
       
   145     static List<int[]> staticIntArrayInList;
       
   146 
       
   147     @ExpectedSignature(descriptor = "staticLongArrayInList", signature = "Ljava/util/List<[J>;")
       
   148     static List<long[]> staticLongArrayInList;
       
   149 
       
   150     @ExpectedSignature(descriptor = "staticCharArrayInList", signature = "Ljava/util/List<[C>;")
       
   151     static List<char[]> staticCharArrayInList;
       
   152 
       
   153     @ExpectedSignature(descriptor = "staticBooleanArrayInList", signature = "Ljava/util/List<[Z>;")
       
   154     static List<boolean[]> staticBooleanArrayInList;
       
   155 
       
   156     @ExpectedSignature(descriptor = "staticFloatArrayInList", signature = "Ljava/util/List<[F>;")
       
   157     static List<float[]> staticFloatArrayInList;
       
   158 
       
   159     @ExpectedSignature(descriptor = "staticDoubleArrayInList", signature = "Ljava/util/List<[D>;")
       
   160     static List<double[]> staticDoubleArrayInList;
       
   161 
       
   162     @ExpectedSignature(descriptor = "staticIntegerInList", signature = "Ljava/util/List<Ljava/lang/Integer;>;")
       
   163     static List<Integer> staticIntegerInList;
       
   164 
       
   165     @ExpectedSignature(descriptor = "staticWildCard", signature = "Ljava/util/Comparator<*>;")
       
   166     static Comparator<?> staticWildCard;
       
   167 
       
   168     @ExpectedSignature(descriptor = "staticBoundsBooleanArray", signature = "Ljava/util/Map<+[Z-[Z>;")
       
   169     static Map<? extends boolean[], ? super boolean[]> staticBoundsBooleanArray;
       
   170 
       
   171     @ExpectedSignature(descriptor = "staticBoundsByteArray", signature = "Ljava/util/Map<+[B-[B>;")
       
   172     static Map<? extends byte[], ? super byte[]> staticBoundsByteArray;
       
   173 
       
   174     @ExpectedSignature(descriptor = "staticBoundsShortArray", signature = "Ljava/util/Map<+[S-[S>;")
       
   175     static Map<? extends short[], ? super short[]> staticBoundsShortArray;
       
   176 
       
   177     @ExpectedSignature(descriptor = "staticBoundsIntArray", signature = "Ljava/util/Map<+[I-[I>;")
       
   178     static Map<? extends int[], ? super int[]> staticBoundsIntArray;
       
   179 
       
   180     @ExpectedSignature(descriptor = "staticBoundsLongArray", signature = "Ljava/util/Map<+[J-[J>;")
       
   181     static Map<? extends long[], ? super long[]> staticBoundsLongArray;
       
   182 
       
   183     @ExpectedSignature(descriptor = "staticBoundsCharArray", signature = "Ljava/util/Map<+[C-[C>;")
       
   184     static Map<? extends char[], ? super char[]> staticBoundsCharArray;
       
   185 
       
   186     @ExpectedSignature(descriptor = "staticBoundsFloatArray", signature = "Ljava/util/Map<+[F-[F>;")
       
   187     static Map<? extends float[], ? super float[]> staticBoundsFloatArray;
       
   188 
       
   189     @ExpectedSignature(descriptor = "staticBoundsDoubleArray", signature = "Ljava/util/Map<+[D-[D>;")
       
   190     static Map<? extends double[], ? super double[]> staticBoundsDoubleArray;
       
   191 
       
   192     @ExpectedSignature(descriptor = "staticBoundsObjectArray",
       
   193             signature = "Ljava/util/Map<+[Ljava/lang/Object;-[Ljava/lang/Object;>;")
       
   194     static Map<? extends Object[], ? super Object[]> staticBoundsObjectArray;
       
   195 
       
   196     static boolean staticBooleanNoSignatureAttribute;
       
   197     static byte staticByteNoSignatureAttribute;
       
   198     static char staticCharNoSignatureAttribute;
       
   199     static short staticShortNoSignatureAttribute;
       
   200     static int staticIntNoSignatureAttribute;
       
   201     static long staticLongNoSignatureAttribute;
       
   202     static float staticFloatNoSignatureAttribute;
       
   203     static double staticDoubleNoSignatureAttribute;
       
   204 
       
   205     static List staticListNoSignatureAttribute;
       
   206 }