1 /* 2 * Copyright (c) 2018, 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 that a VerifyError exception is thrown when trying to pass a null 26 // when the formal parameter is a value type. 27 // 28 // // Java program emulating the jcod contents. 29 // public value final class NoNullVT { 30 // final int x; 31 // final int y; 32 // 33 // private NoNullVT() { 34 // x = 0; 35 // y = 0; 36 // } 37 // 38 // public int getX() { return x; } 39 // public int getY() { return y; } 40 // 41 // public boolean isSameNoNullVT(NoNullVT that) { 42 // return this.getX() == that.getX() && this.getY() == that.getY(); 43 // } 44 // 45 // public boolean equals(Object o) { 46 // if(o instanceof NoNullVT) { 47 // return ((NoNullVT)o).x == x && ((NoNullVT)o).y == y; 48 // } else { 49 // return false; 50 // } 51 // } 52 // 53 // public static NoNullVT createNoNullVT(int x, int y) { 54 // NoNullVT p = NoNullVT.default; 55 // p = __WithField(p.x, x); 56 // p = __WithField(p.y, y); 57 // return p; 58 // } 59 // 60 // public static void main(String[] args) { 61 // String str = null; 62 // NoNullVT a = createNoNullVT(3, 4); 63 // NoNullVT b = createNoNullVT(2, 4); 64 // boolean res = a.isSameNoNullVT(null); // Should throw VerifyError 65 // } 66 // } 67 68 69 class NoNullVT { 70 0xCAFEBABE; 71 0; // minor version 72 57; // version 73 [86] { // Constant Pool 74 ; // first element is empty 75 Method #54 #13; // #1 at 0x0A 76 Field #10 #47; // #2 at 0x0F 77 InvokeDynamic 2s #52; // #3 at 0x14 78 InvokeDynamic 1s #29; // #4 at 0x19 79 Method #10 #24; // #5 at 0x1E 80 Method #10 #72; // #6 at 0x23 81 Field #10 #26; // #7 at 0x28 82 Method #63 #40; // #8 at 0x2D 83 InvokeDynamic 0s #80; // #9 at 0x32 84 class #68; // #10 at 0x37 85 Method #10 #27; // #11 at 0x3A 86 Method #10 #73; // #12 at 0x3F 87 NameAndType #75 #51; // #13 at 0x44 88 Utf8 "java/lang/invoke/ValueBootstrapMethods"; // #14 at 0x49 89 Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #15 at 0x72 90 Utf8 "createNoNullVT"; // #16 at 0x9A 91 MethodHandle 6b #36; // #17 at 0xAC 92 Utf8 "SourceFile"; // #18 at 0xB0 93 class #14; // #19 at 0xBD 94 Utf8 "Lookup"; // #20 at 0xC0 95 class #15; // #21 at 0xC9 96 Utf8 "hashCode"; // #22 at 0xCC 97 Utf8 "(Ljava/lang/Object;)Ljava/lang/Object;"; // #23 at 0xD7 98 NameAndType #65 #62; // #24 at 0x0100 99 Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;"; // #25 at 0x0105 100 NameAndType #82 #28; // #26 at 0x01A0 101 NameAndType #16 #61; // #27 at 0x01A5 102 Utf8 "I"; // #28 at 0x01AA 103 NameAndType #22 #55; // #29 at 0x01AE 104 Utf8 "Code"; // #30 at 0x01B3 105 Utf8 "requireNonNull"; // #31 at 0x01BA 106 String #45; // #32 at 0x01CB 107 Utf8 "StackMapTable"; // #33 at 0x01CE 108 NameAndType #77 #25; // #34 at 0x01DE 109 Utf8 "NoNullVT.jasm"; // #35 at 0x01E3 110 Method #83 #34; // #36 at 0x01F4 111 Utf8 "([Ljava/lang/String;)V"; // #37 at 0x01F9 112 Utf8 "$makeValue$"; // #38 at 0x0212 113 Utf8 "BootstrapMethods"; // #39 at 0x0220 114 NameAndType #31 #23; // #40 at 0x0233 115 Utf8 "toString"; // #41 at 0x0238 116 Utf8 "isSameNoNullVT"; // #42 at 0x0243 117 Utf8 "java/lang/invoke/MethodHandles"; // #43 at 0x0255 118 Utf8 "(Ljava/lang/Object;)Z"; // #44 at 0x0276 119 Utf8 "NoNullVT: x= y="; // #45 at 0x028E 120 Utf8 "java/lang/Object"; // #46 at 0x02A3 121 NameAndType #79 #28; // #47 at 0x02B6 122 class #43; // #48 at 0x02BB 123 NameAndType #59 #66; // #49 at 0x02BE 124 Utf8 "equals"; // #50 at 0x02C3 125 Utf8 "()V"; // #51 at 0x02CC 126 NameAndType #84 #53; // #52 at 0x02D2 127 Utf8 "(Ljava/lang/Object;)J"; // #53 at 0x02D7 128 class #46; // #54 at 0x02EF 129 Utf8 "(Ljava/lang/Object;)I"; // #55 at 0x02F2 130 Utf8 "java/util/Objects"; // #56 at 0x030A 131 Utf8 "main"; // #57 at 0x031E 132 Method #19 #49; // #58 at 0x0325 133 Utf8 "makeBootstrapMethod"; // #59 at 0x032A 134 Utf8 "()J"; // #60 at 0x0340 135 Utf8 "(II)QNoNullVT;"; // #61 at 0x0346 136 Utf8 "()I"; // #62 at 0x0358 137 class #56; // #63 at 0x035E 138 Utf8 "getY"; // #64 at 0x0361 139 Utf8 "getX"; // #65 at 0x0368 140 Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; // #66 at 0x036F 141 Utf8 "InnerClasses"; // #67 at 0x03E5 142 Utf8 "NoNullVT"; // #68 at 0x03F4 143 Utf8 "(QNoNullVT;)Z"; // #69 at 0x0400 144 MethodHandle 6b #58; // #70 at 0x0411 145 MethodHandle 6b #58; // #71 at 0x0415 146 NameAndType #64 #62; // #72 at 0x0419 147 NameAndType #42 #69; // #73 at 0x041E 148 Utf8 "java/lang/invoke/StringConcatFactory"; // #74 at 0x0423 149 Utf8 "<init>"; // #75 at 0x044A 150 Utf8 "()Ljava/lang/String;"; // #76 at 0x0453 151 Utf8 "makeConcatWithConstants"; // #77 at 0x046A 152 Utf8 "()QNoNullVT;"; // #78 at 0x0484 153 Utf8 "y"; // #79 at 0x0494 154 NameAndType #77 #85; // #80 at 0x0498 155 Utf8 "ValueTypes"; // #81 at 0x049D 156 Utf8 "x"; // #82 at 0x04AA 157 class #74; // #83 at 0x04AE 158 Utf8 "longHashCode"; // #84 at 0x04B1 159 Utf8 "(II)Ljava/lang/String;"; // #85 at 0x04C0 160 } // Constant Pool 161 162 0x0131; // access [ ACC_PUBLIC ACC_SUPER ACC_FINAL ] 163 #10;// this_cpx 164 #54;// super_cpx 165 166 [0] { // Interfaces 167 } // Interfaces 168 169 [2] { // fields 170 { // Member at 0x04E3 171 0x0010; // access 172 #82; // name_cpx 173 #28; // sig_cpx 174 [0] { // Attributes 175 } // Attributes 176 } // Member 177 ; 178 { // Member at 0x04EB 179 0x0010; // access 180 #79; // name_cpx 181 #28; // sig_cpx 182 [0] { // Attributes 183 } // Attributes 184 } // Member 185 } // fields 186 187 [11] { // methods 188 { // Member at 0x04F5 189 0x0002; // access 190 #75; // name_cpx 191 #51; // sig_cpx 192 [1] { // Attributes 193 Attr(#30, 17) { // Code at 0x04FD 194 1; // max_stack 195 1; // max_locals 196 Bytes[5]{ 197 0x2AB70001B1; 198 }; 199 [0] { // Traps 200 } // end Traps 201 [0] { // Attributes 202 } // Attributes 203 } // end Code 204 } // Attributes 205 } // Member 206 ; 207 { // Member at 0x0514 208 0x0001; // access 209 #65; // name_cpx 210 #62; // sig_cpx 211 [1] { // Attributes 212 Attr(#30, 17) { // Code at 0x051C 213 1; // max_stack 214 1; // max_locals 215 Bytes[5]{ 216 0x2AB40007AC; 217 }; 218 [0] { // Traps 219 } // end Traps 220 [0] { // Attributes 221 } // Attributes 222 } // end Code 223 } // Attributes 224 } // Member 225 ; 226 { // Member at 0x0533 227 0x0001; // access 228 #64; // name_cpx 229 #62; // sig_cpx 230 [1] { // Attributes 231 Attr(#30, 17) { // Code at 0x053B 232 1; // max_stack 233 1; // max_locals 234 Bytes[5]{ 235 0x2AB40002AC; 236 }; 237 [0] { // Traps 238 } // end Traps 239 [0] { // Attributes 240 } // Attributes 241 } // end Code 242 } // Attributes 243 } // Member 244 ; 245 { // Member at 0x0552 246 0x0001; // access 247 #42; // name_cpx 248 #69; // sig_cpx 249 [1] { // Attributes 250 Attr(#30, 51) { // Code at 0x055A 251 2; // max_stack 252 2; // max_locals 253 Bytes[28]{ 254 0x2AB600052BB60005; 255 0xA000122AB600062B; 256 0xB60006A0000704A7; 257 0x000403AC; 258 }; 259 [0] { // Traps 260 } // end Traps 261 [1] { // Attributes 262 Attr(#33, 5) { // StackMapTable at 0x0588 263 [2] { // 264 26b; // same_frame 265 64b, [1]z{1b}; // same_locals_1_stack_item_frame 266 } 267 } // end StackMapTable 268 } // Attributes 269 } // end Code 270 } // Attributes 271 } // Member 272 ; 273 { // Member at 0x0593 274 0x0001; // access 275 #41; // name_cpx 276 #76; // sig_cpx 277 [1] { // Attributes 278 Attr(#30, 26) { // Code at 0x059B 279 2; // max_stack 280 1; // max_locals 281 Bytes[14]{ 282 0x2AB600052AB60006; 283 0xBA00090000B0; 284 }; 285 [0] { // Traps 286 } // end Traps 287 [0] { // Attributes 288 } // Attributes 289 } // end Code 290 } // Attributes 291 } // Member 292 ; 293 { // Member at 0x05BB 294 0x0001; // access 295 #50; // name_cpx 296 #44; // sig_cpx 297 [1] { // Attributes 298 Attr(#30, 77) { // Code at 0x05C3 299 2; // max_stack 300 2; // max_locals 301 Bytes[53]{ 302 0x2BC1000A99002F2B; 303 0x59B8000857C0000A; 304 0xB400072AB40007A0; 305 0x001A2B59B8000857; 306 0xC0000AB400022AB4; 307 0x0002A0000704A700; 308 0x0403AC03AC; 309 }; 310 [0] { // Traps 311 } // end Traps 312 [1] { // Attributes 313 Attr(#33, 6) { // StackMapTable at 0x060A 314 [3] { // 315 49b; // same_frame 316 64b, [1]z{1b}; // same_locals_1_stack_item_frame 317 0b; // same_frame 318 } 319 } // end StackMapTable 320 } // Attributes 321 } // end Code 322 } // Attributes 323 } // Member 324 ; 325 { // Member at 0x0616 326 0x0009; // access 327 #16; // name_cpx 328 #61; // sig_cpx 329 [1] { // Attributes 330 Attr(#30, 32) { // Code at 0x061E 331 2; // max_stack 332 3; // max_locals 333 Bytes[20]{ 334 0xCB000A4D1A2C5FCC; 335 0x00074D1B2C5FCC00; 336 0x024D2CB0; 337 }; 338 [0] { // Traps 339 } // end Traps 340 [0] { // Attributes 341 } // Attributes 342 } // end Code 343 } // Attributes 344 } // Member 345 ; 346 { // Member at 0x0644 347 0x0009; // access 348 #57; // name_cpx 349 #37; // sig_cpx 350 [1] { // Attributes 351 Attr(#30, 34) { // Code at 0x064C 352 2; // max_stack 353 5; // max_locals 354 Bytes[22]{ 355 0x014C0607B8000B4D; 356 0x0507B8000B4E2C2B; 357 0xB6000C3604B1; 358 }; 359 [0] { // Traps 360 } // end Traps 361 [0] { // Attributes 362 } // Attributes 363 } // end Code 364 } // Attributes 365 } // Member 366 ; 367 { // Member at 0x0674 368 0x0011; // access 369 #22; // name_cpx 370 #62; // sig_cpx 371 [1] { // Attributes 372 Attr(#30, 19) { // Code at 0x067C 373 1; // max_stack 374 1; // max_locals 375 Bytes[7]{ 376 0x2ABA00040000AC; 377 }; 378 [0] { // Traps 379 } // end Traps 380 [0] { // Attributes 381 } // Attributes 382 } // end Code 383 } // Attributes 384 } // Member 385 ; 386 { // Member at 0x0695 387 0x0011; // access 388 #84; // name_cpx 389 #60; // sig_cpx 390 [1] { // Attributes 391 Attr(#30, 19) { // Code at 0x069D 392 2; // max_stack 393 1; // max_locals 394 Bytes[7]{ 395 0x2ABA00030000AD; 396 }; 397 [0] { // Traps 398 } // end Traps 399 [0] { // Attributes 400 } // Attributes 401 } // end Code 402 } // Attributes 403 } // Member 404 ; 405 { // Member at 0x06B6 406 0x100A; // access 407 #38; // name_cpx 408 #78; // sig_cpx 409 [1] { // Attributes 410 Attr(#30, 32) { // Code at 0x06BE 411 2; // max_stack 412 1; // max_locals 413 Bytes[20]{ 414 0xCB000A4B032A5FCC; 415 0x00074B032A5FCC00; 416 0x024B2AB0; 417 }; 418 [0] { // Traps 419 } // end Traps 420 [0] { // Attributes 421 } // Attributes 422 } // end Code 423 } // Attributes 424 } // Member 425 } // methods 426 427 [4] { // Attributes 428 Attr(#18, 2) { // SourceFile at 0x06E6 429 #35; 430 } // end SourceFile 431 ; 432 Attr(#67, 10) { // InnerClasses at 0x06EE 433 [1] { // InnerClasses 434 #21 #48 #20 25; // at 0x06FE 435 } 436 } // end InnerClasses 437 ; 438 Attr(#39, 16) { // BootstrapMethods at 0x06FE 439 [3] { // bootstrap_methods 440 { // bootstrap_method 441 #17; // bootstrap_method_ref 442 [1] { // bootstrap_arguments 443 #32; // at 0x070C 444 } // bootstrap_arguments 445 } // bootstrap_method 446 ; 447 { // bootstrap_method 448 #71; // bootstrap_method_ref 449 [0] { // bootstrap_arguments 450 } // bootstrap_arguments 451 } // bootstrap_method 452 ; 453 { // bootstrap_method 454 #70; // bootstrap_method_ref 455 [0] { // bootstrap_arguments 456 } // bootstrap_arguments 457 } // bootstrap_method 458 } 459 } // end BootstrapMethods 460 ; 461 Attr(#81, 4) { // ValueTypes at 0x0714 462 0x0001000A; 463 } // end ValueTypes 464 } // Attributes 465 } // end class NoNullVT