1 /*
  2  * Copyright (c) 2018, 2022, 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  * This test contains a incorrect ldc instruction of a condy whose loadable
 26  * constant is a double. VerifyError expected.
 27  */
 28 
 29 super class CondyBadLDC
 30 	version 55:0
 31 {
 32 
 33 
 34 public Method "<init>":"()V"
 35 	stack 1 locals 1
 36 {
 37 		aload_0;
 38 		invokespecial	Method java/lang/Object."<init>":"()V";
 39 		return;
 40 }
 41 
 42 public static Method intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;"
 43 	throws java/lang/Throwable
 44 	stack 4 locals 6
 45 {
 46 		aload_1;
 47 		astore	4;
 48 		iconst_m1;
 49 		istore	5;
 50 		aload	4;
 51 		invokevirtual	Method java/lang/String.hashCode:"()I";
 52 		lookupswitch{ //11
 53 		-2001159796: L238;
 54 		-1538095928: L272;
 55 		-891985903: L255;
 56 		66: L108;
 57 		67: L124;
 58 		68: L140;
 59 		70: L156;
 60 		73: L172;
 61 		74: L188;
 62 		83: L204;
 63 		90: L221;
 64 		default: L286 };
 65 	L108:	stack_frame_type append;
 66 		locals_map class java/lang/String, int;
 67 		aload	4;
 68 		ldc	String "B";
 69 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
 70 		ifeq	L286;
 71 		iconst_0;
 72 		istore	5;
 73 		goto	L286;
 74 	L124:	stack_frame_type same;
 75 		aload	4;
 76 		ldc	String "C";
 77 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
 78 		ifeq	L286;
 79 		iconst_1;
 80 		istore	5;
 81 		goto	L286;
 82 	L140:	stack_frame_type same;
 83 		aload	4;
 84 		ldc	String "D";
 85 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
 86 		ifeq	L286;
 87 		iconst_2;
 88 		istore	5;
 89 		goto	L286;
 90 	L156:	stack_frame_type same;
 91 		aload	4;
 92 		ldc	String "F";
 93 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
 94 		ifeq	L286;
 95 		iconst_3;
 96 		istore	5;
 97 		goto	L286;
 98 	L172:	stack_frame_type same;
 99 		aload	4;
100 		ldc	String "I";
101 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
102 		ifeq	L286;
103 		iconst_4;
104 		istore	5;
105 		goto	L286;
106 	L188:	stack_frame_type same;
107 		aload	4;
108 		ldc	String "J";
109 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
110 		ifeq	L286;
111 		iconst_5;
112 		istore	5;
113 		goto	L286;
114 	L204:	stack_frame_type same;
115 		aload	4;
116 		ldc	String "S";
117 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
118 		ifeq	L286;
119 		bipush	6;
120 		istore	5;
121 		goto	L286;
122 	L221:	stack_frame_type same;
123 		aload	4;
124 		ldc	String "Z";
125 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
126 		ifeq	L286;
127 		bipush	7;
128 		istore	5;
129 		goto	L286;
130 	L238:	stack_frame_type same;
131 		aload	4;
132 		ldc	String "nullRef";
133 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
134 		ifeq	L286;
135 		bipush	8;
136 		istore	5;
137 		goto	L286;
138 	L255:	stack_frame_type same;
139 		aload	4;
140 		ldc	String "string";
141 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
142 		ifeq	L286;
143 		bipush	9;
144 		istore	5;
145 		goto	L286;
146 	L272:	stack_frame_type same;
147 		aload	4;
148 		ldc	String "stringArray";
149 		invokevirtual	Method java/lang/String.equals:"(Ljava/lang/Object;)Z";
150 		ifeq	L286;
151 		bipush	10;
152 		istore	5;
153 	L286:	stack_frame_type same;
154 		iload	5;
155 		tableswitch{ //0 to 10
156 		0: L348;
157 		1: L354;
158 		2: L360;
159 		3: L366;
160 		4: L372;
161 		5: L377;
162 		6: L383;
163 		7: L389;
164 		8: L402;
165 		9: L404;
166 		10: L407;
167 		default: L422 };
168 	L348:	stack_frame_type same;
169 		iload_3;
170 		i2b;
171 		invokestatic	Method java/lang/Byte.valueOf:"(B)Ljava/lang/Byte;";
172 		areturn;
173 	L354:	stack_frame_type same;
174 		iload_3;
175 		i2c;
176 		invokestatic	Method java/lang/Character.valueOf:"(C)Ljava/lang/Character;";
177 		areturn;
178 	L360:	stack_frame_type same;
179 		iload_3;
180 		i2d;
181 		invokestatic	Method java/lang/Double.valueOf:"(D)Ljava/lang/Double;";
182 		areturn;
183 	L366:	stack_frame_type same;
184 		iload_3;
185 		i2f;
186 		invokestatic	Method java/lang/Float.valueOf:"(F)Ljava/lang/Float;";
187 		areturn;
188 	L372:	stack_frame_type same;
189 		iload_3;
190 		invokestatic	Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;";
191 		areturn;
192 	L377:	stack_frame_type same;
193 		iload_3;
194 		i2l;
195 		invokestatic	Method java/lang/Long.valueOf:"(J)Ljava/lang/Long;";
196 		areturn;
197 	L383:	stack_frame_type same;
198 		iload_3;
199 		i2s;
200 		invokestatic	Method java/lang/Short.valueOf:"(S)Ljava/lang/Short;";
201 		areturn;
202 	L389:	stack_frame_type same;
203 		iload_3;
204 		ifle	L397;
205 		iconst_1;
206 		goto	L398;
207 	L397:	stack_frame_type same;
208 		iconst_0;
209 	L398:	stack_frame_type stack1;
210 		stack_map int;
211 		invokestatic	Method java/lang/Boolean.valueOf:"(Z)Ljava/lang/Boolean;";
212 		areturn;
213 	L402:	stack_frame_type same;
214 		aconst_null;
215 		areturn;
216 	L404:	stack_frame_type same;
217 		ldc	String "string";
218 		areturn;
219 	L407:	stack_frame_type same;
220 		iconst_2;
221 		anewarray	class java/lang/String;
222 		dup;
223 		iconst_0;
224 		ldc	String "string";
225 		aastore;
226 		dup;
227 		iconst_1;
228 		ldc	String "string";
229 		aastore;
230 		areturn;
231 	L422:	stack_frame_type same;
232 		new	class java/lang/BootstrapMethodError;
233 		dup;
234 		ldc	String "Failure to generate a dynamic constant";
235 		invokespecial	Method java/lang/BootstrapMethodError."<init>":"(Ljava/lang/String;)V";
236 		athrow;
237 }
238 
239 public static Method D:"()D"
240 	stack 2 locals 0
241 {
242                 // ldc of a double will yield a VerifyError, should be an ldc2_w instruction
243 		ldc	Dynamic REF_invokeStatic:CondyBadLDC.intConversion:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;I)Ljava/lang/Object;":D:"D" int 2147483647;
244 		dreturn;
245 }
246 
247 public static Method main:"([Ljava/lang/String;)V"
248 	stack 2 locals 1
249 {
250 		invokestatic	Method D:"()D";
251 		return;
252 }
253 
254 } // end Class CondyBadLDC