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