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