|
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 constructors. |
|
28 * @library /tools/lib /tools/javac/lib ../lib |
|
29 * @build TestBase TestResult InMemoryFileManager ToolBox |
|
30 * @build ConstructorTest Driver ExpectedSignature ExpectedSignatureContainer |
|
31 * @run main Driver ConstructorTest |
|
32 */ |
|
33 |
|
34 import java.lang.ref.ReferenceQueue; |
|
35 import java.util.*; |
|
36 |
|
37 @ExpectedSignature(descriptor = "ConstructorTest", signature = "<T:Ljava/lang/Object;>Ljava/lang/Object;") |
|
38 public class ConstructorTest<T> { |
|
39 |
|
40 @ExpectedSignature(descriptor = "<init>(java.lang.Object, boolean)", signature = "(TT;Z)V") |
|
41 ConstructorTest(T a, boolean b) { |
|
42 } |
|
43 |
|
44 @ExpectedSignature(descriptor = "<init>(java.lang.Object, byte)", signature = "(TT;B)V") |
|
45 ConstructorTest(T a, byte b) { |
|
46 } |
|
47 |
|
48 @ExpectedSignature(descriptor = "<init>(java.lang.Object, char)", signature = "(TT;C)V") |
|
49 ConstructorTest(T a, char b) { |
|
50 } |
|
51 |
|
52 @ExpectedSignature(descriptor = "<init>(java.lang.Object, short)", signature = "(TT;S)V") |
|
53 ConstructorTest(T a, short b) { |
|
54 } |
|
55 |
|
56 @ExpectedSignature(descriptor = "<init>(java.lang.Object, int)", signature = "(TT;I)V") |
|
57 ConstructorTest(T a, int b) { |
|
58 } |
|
59 |
|
60 @ExpectedSignature(descriptor = "<init>(java.lang.Object, long)", signature = "(TT;J)V") |
|
61 ConstructorTest(T a, long b) { |
|
62 } |
|
63 |
|
64 @ExpectedSignature(descriptor = "<init>(java.lang.Object, float)", signature = "(TT;F)V") |
|
65 ConstructorTest(T a, float b) { |
|
66 } |
|
67 |
|
68 @ExpectedSignature(descriptor = "<init>(java.lang.Object, double)", signature = "(TT;D)V") |
|
69 ConstructorTest(T a, double b) { |
|
70 } |
|
71 |
|
72 @ExpectedSignature(descriptor = "<init>(java.lang.Object, java.lang.Runnable)", signature = "(TT;Ljava/lang/Runnable;)V") |
|
73 ConstructorTest(T a, Runnable r) { |
|
74 } |
|
75 |
|
76 @ExpectedSignature(descriptor = "<init>(java.lang.Object, boolean[])", signature = "(TT;[Z)V") |
|
77 ConstructorTest(T a, boolean[] b) { |
|
78 } |
|
79 |
|
80 @ExpectedSignature(descriptor = "<init>(java.lang.Object, byte[])", signature = "(TT;[B)V") |
|
81 ConstructorTest(T a, byte[] b) { |
|
82 } |
|
83 |
|
84 @ExpectedSignature(descriptor = "<init>(java.lang.Object, char[])", signature = "(TT;[C)V") |
|
85 ConstructorTest(T a, char[] b) { |
|
86 } |
|
87 |
|
88 @ExpectedSignature(descriptor = "<init>(java.lang.Object, short[])", signature = "(TT;[S)V") |
|
89 ConstructorTest(T a, short[] b) { |
|
90 } |
|
91 |
|
92 @ExpectedSignature(descriptor = "<init>(java.lang.Object, int[])", signature = "(TT;[I)V") |
|
93 ConstructorTest(T a, int[] b) { |
|
94 } |
|
95 |
|
96 @ExpectedSignature(descriptor = "<init>(java.lang.Object, long[])", signature = "(TT;[J)V") |
|
97 ConstructorTest(T a, long[] b) { |
|
98 } |
|
99 |
|
100 @ExpectedSignature(descriptor = "<init>(java.lang.Object, float[])", signature = "(TT;[F)V") |
|
101 ConstructorTest(T a, float[] b) { |
|
102 } |
|
103 |
|
104 @ExpectedSignature(descriptor = "<init>(java.lang.Object, double[])", signature = "(TT;[D)V") |
|
105 ConstructorTest(T a, double[] b) { |
|
106 } |
|
107 |
|
108 @ExpectedSignature(descriptor = "<init>(java.lang.Object, java.lang.Runnable[])", signature = "(TT;[Ljava/lang/Runnable;)V") |
|
109 ConstructorTest(T a, Runnable[] r) { |
|
110 } |
|
111 |
|
112 @ExpectedSignature(descriptor = "<init>(java.lang.Object[])", signature = "([TT;)V") |
|
113 ConstructorTest(T[] a) { |
|
114 } |
|
115 |
|
116 @ExpectedSignature(descriptor = "<init>(java.lang.Runnable[])", |
|
117 signature = "<T::Ljava/lang/Runnable;>([TT;)V") |
|
118 <T extends Runnable> ConstructorTest(T...a) { |
|
119 } |
|
120 |
|
121 @ExpectedSignature(descriptor = "<init>(java.util.Map)", signature = "(Ljava/util/Map<**>;)V") |
|
122 ConstructorTest(Map<?, ?> a) { |
|
123 } |
|
124 |
|
125 @ExpectedSignature(descriptor = "<init>(java.lang.Object)", signature = "(TT;)V") |
|
126 ConstructorTest(T a) { |
|
127 } |
|
128 |
|
129 @ExpectedSignature(descriptor = "<init>(java.util.Set, java.util.Set)", |
|
130 signature = "<E::Ljava/util/Set<+TT;>;>(TE;TE;)V") |
|
131 <E extends Set<? extends T>> ConstructorTest(E a, E b) { |
|
132 } |
|
133 |
|
134 @ExpectedSignature(descriptor = "<init>(java.lang.ref.ReferenceQueue, java.lang.ref.ReferenceQueue)", |
|
135 signature = "<E:Ljava/lang/ref/ReferenceQueue<-TT;>;:Ljava/util/Map<-TT;+TT;>;>(TE;TE;)V") |
|
136 <E extends ReferenceQueue<? super T> & Map<? super T, ? extends T>> ConstructorTest(E a, E b) { |
|
137 } |
|
138 |
|
139 @ExpectedSignature(descriptor = "<init>(java.util.List)", signature = "(Ljava/util/List<+TT;>;)V") |
|
140 ConstructorTest(List<? extends T> b) { |
|
141 } |
|
142 |
|
143 @ExpectedSignature(descriptor = "<init>(java.util.Set)", signature = "(Ljava/util/Set<-TT;>;)V") |
|
144 ConstructorTest(Set<? super T> b) { |
|
145 } |
|
146 |
|
147 @ExpectedSignature(descriptor = "<init>(java.lang.Runnable)", signature = "<E::Ljava/lang/Runnable;>(TE;)V") |
|
148 <E extends Runnable> ConstructorTest(E a) { |
|
149 } |
|
150 |
|
151 @ExpectedSignature(descriptor = "<init>(java.lang.Object, java.lang.Object)", signature = "<E:TT;>(TT;TE;)V") |
|
152 <E extends T> ConstructorTest(T a, E b) { |
|
153 } |
|
154 |
|
155 // no Signature attribute |
|
156 ConstructorTest(boolean b) { |
|
157 } |
|
158 |
|
159 // no Signature attribute |
|
160 ConstructorTest(HashMap a) { |
|
161 } |
|
162 |
|
163 // no Signature attribute |
|
164 ConstructorTest(boolean[] b) { |
|
165 } |
|
166 |
|
167 // no Signature attribute |
|
168 ConstructorTest(HashMap[] a) { |
|
169 } |
|
170 } |