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