1 /* 2 * Copyright (c) 2024, 2024, 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 file contains multiple illegal inline type classes that should cause 26 // ClassFormatError exceptions when attempted to be loaded. 27 // 28 // Many of these test were originally generated from this Java file and then 29 // field modifiers are changed to cause a ClassFormatError exceptions. 30 // 31 // public value class Value { 32 // static int si = 0; 33 // int i = 0; 34 //} 35 36 37 // A field has both ACC_FINAL and ACC_VOLATILE set 38 // 39 class FinalAndVolatile { 40 0xCAFEBABE; 41 65535; // minor version 42 67; // version 43 [] { // Constant Pool 44 ; // first element is empty 45 Field #2 #3; // #1 46 class #4; // #2 47 NameAndType #5 #6; // #3 48 Utf8 "FinalAndVolatile"; // #4 49 Utf8 "i"; // #5 50 Utf8 "I"; // #6 51 Method #8 #9; // #7 52 class #10; // #8 53 NameAndType #11 #12; // #9 54 Utf8 "java/lang/Object"; // #10 55 Utf8 "<init>"; // #11 56 Utf8 "()V"; // #12 57 Field #2 #14; // #13 58 NameAndType #15 #6; // #14 59 Utf8 "si"; // #15 60 Utf8 "ConstantValue"; // #16 61 int 0x00000000; // #17 62 Utf8 "Code"; // #18 63 Utf8 "LineNumberTable"; // #19 64 Utf8 "<clinit>"; // #20 65 Utf8 "SourceFile"; // #21 66 Utf8 "FinalAndVolatile.java"; // #22 67 } // Constant Pool 68 69 0x0011; // access 70 #2;// this_cpx 71 #8;// super_cpx 72 73 [] { // Interfaces 74 } // Interfaces 75 76 [] { // Fields 77 { // field 78 0x0008; // access 79 #15; // name_index 80 #6; // descriptor_index 81 [] { // Attributes 82 } // Attributes 83 } 84 ; 85 { // field 86 0x0850; // access 87 #5; // name_index 88 #6; // descriptor_index 89 [] { // Attributes 90 Attr(#16) { // ConstantValue 91 #17; 92 } // end ConstantValue 93 } // Attributes 94 } 95 } // Fields 96 97 [] { // Methods 98 { // method 99 0x0001; // access 100 #11; // name_index 101 #12; // descriptor_index 102 [] { // Attributes 103 Attr(#18) { // Code 104 2; // max_stack 105 1; // max_locals 106 Bytes[]{ 107 0x2A03B500012AB700; 108 0x07B1; 109 } 110 [] { // Traps 111 } // end Traps 112 [] { // Attributes 113 Attr(#19) { // LineNumberTable 114 [] { // line_number_table 115 0 3; 116 5 1; 117 9 3; 118 } 119 } // end LineNumberTable 120 } // Attributes 121 } // end Code 122 } // Attributes 123 } 124 ; 125 { // method 126 0x0008; // access 127 #20; // name_index 128 #12; // descriptor_index 129 [] { // Attributes 130 Attr(#18) { // Code 131 1; // max_stack 132 0; // max_locals 133 Bytes[]{ 134 0x03B3000DB1; 135 } 136 [] { // Traps 137 } // end Traps 138 [] { // Attributes 139 Attr(#19) { // LineNumberTable 140 [] { // line_number_table 141 0 2; 142 } 143 } // end LineNumberTable 144 } // Attributes 145 } // end Code 146 } // Attributes 147 } 148 } // Methods 149 150 [] { // Attributes 151 Attr(#21) { // SourceFile 152 #22; 153 } // end SourceFile 154 } // Attributes 155 } // end class FinalAndVolatile 156 157 158 // A field has both ACC_STRICT and ACC_STATIC set 159 // 160 class StrictAndStatic { 161 0xCAFEBABE; 162 65535; // minor version 163 67; // version 164 [] { // Constant Pool 165 ; // first element is empty 166 Field #2 #3; // #1 167 class #4; // #2 168 NameAndType #5 #6; // #3 169 Utf8 "StrictAndStatic"; // #4 170 Utf8 "i"; // #5 171 Utf8 "I"; // #6 172 Method #8 #9; // #7 173 class #10; // #8 174 NameAndType #11 #12; // #9 175 Utf8 "java/lang/Object"; // #10 176 Utf8 "<init>"; // #11 177 Utf8 "()V"; // #12 178 Field #2 #14; // #13 179 NameAndType #15 #6; // #14 180 Utf8 "si"; // #15 181 Utf8 "ConstantValue"; // #16 182 int 0x00000000; // #17 183 Utf8 "Code"; // #18 184 Utf8 "LineNumberTable"; // #19 185 Utf8 "<clinit>"; // #20 186 Utf8 "SourceFile"; // #21 187 Utf8 "StrictAndStatic.java"; // #22 188 } // Constant Pool 189 190 0x0011; // access 191 #2;// this_cpx 192 #8;// super_cpx 193 194 [] { // Interfaces 195 } // Interfaces 196 197 [] { // Fields 198 { // field 199 0x0808; // access 200 #15; // name_index 201 #6; // descriptor_index 202 [] { // Attributes 203 } // Attributes 204 } 205 ; 206 { // field 207 0x0810; // access 208 #5; // name_index 209 #6; // descriptor_index 210 [] { // Attributes 211 Attr(#16) { // ConstantValue 212 #17; 213 } // end ConstantValue 214 } // Attributes 215 } 216 } // Fields 217 218 [] { // Methods 219 { // method 220 0x0001; // access 221 #11; // name_index 222 #12; // descriptor_index 223 [] { // Attributes 224 Attr(#18) { // Code 225 2; // max_stack 226 1; // max_locals 227 Bytes[]{ 228 0x2A03B500012AB700; 229 0x07B1; 230 } 231 [] { // Traps 232 } // end Traps 233 [] { // Attributes 234 Attr(#19) { // LineNumberTable 235 [] { // line_number_table 236 0 3; 237 5 1; 238 9 3; 239 } 240 } // end LineNumberTable 241 } // Attributes 242 } // end Code 243 } // Attributes 244 } 245 ; 246 { // method 247 0x0008; // access 248 #20; // name_index 249 #12; // descriptor_index 250 [] { // Attributes 251 Attr(#18) { // Code 252 1; // max_stack 253 0; // max_locals 254 Bytes[]{ 255 0x03B3000DB1; 256 } 257 [] { // Traps 258 } // end Traps 259 [] { // Attributes 260 Attr(#19) { // LineNumberTable 261 [] { // line_number_table 262 0 2; 263 } 264 } // end LineNumberTable 265 } // Attributes 266 } // end Code 267 } // Attributes 268 } 269 } // Methods 270 271 [] { // Attributes 272 Attr(#21) { // SourceFile 273 #22; 274 } // end SourceFile 275 } // Attributes 276 } // end class StrictAndStatic 277 278 279 // A field has ACC_STRICT set without ACC_FINAL being set 280 // 281 class StrictNotFinal { 282 0xCAFEBABE; 283 65535; // minor version 284 67; // version 285 [] { // Constant Pool 286 ; // first element is empty 287 Field #2 #3; // #1 288 class #4; // #2 289 NameAndType #5 #6; // #3 290 Utf8 "StrictNotFinal"; // #4 291 Utf8 "i"; // #5 292 Utf8 "I"; // #6 293 Method #8 #9; // #7 294 class #10; // #8 295 NameAndType #11 #12; // #9 296 Utf8 "java/lang/Object"; // #10 297 Utf8 "<init>"; // #11 298 Utf8 "()V"; // #12 299 Field #2 #14; // #13 300 NameAndType #15 #6; // #14 301 Utf8 "si"; // #15 302 Utf8 "ConstantValue"; // #16 303 int 0x00000000; // #17 304 Utf8 "Code"; // #18 305 Utf8 "LineNumberTable"; // #19 306 Utf8 "<clinit>"; // #20 307 Utf8 "SourceFile"; // #21 308 Utf8 "StrictNotFinal.java"; // #22 309 } // Constant Pool 310 311 0x0011; // access 312 #2;// this_cpx 313 #8;// super_cpx 314 315 [] { // Interfaces 316 } // Interfaces 317 318 [] { // Fields 319 { // field 320 0x0008; // access 321 #15; // name_index 322 #6; // descriptor_index 323 [] { // Attributes 324 } // Attributes 325 } 326 ; 327 { // field 328 0x0810; // access 329 #5; // name_index 330 #6; // descriptor_index 331 [] { // Attributes 332 Attr(#16) { // ConstantValue 333 #17; 334 } // end ConstantValue 335 } // Attributes 336 } 337 } // Fields 338 339 [] { // Methods 340 { // method 341 0x0001; // access 342 #11; // name_index 343 #12; // descriptor_index 344 [] { // Attributes 345 Attr(#18) { // Code 346 2; // max_stack 347 1; // max_locals 348 Bytes[]{ 349 0x2A03B500012AB700; 350 0x07B1; 351 } 352 [] { // Traps 353 } // end Traps 354 [] { // Attributes 355 Attr(#19) { // LineNumberTable 356 [] { // line_number_table 357 0 3; 358 5 1; 359 9 3; 360 } 361 } // end LineNumberTable 362 } // Attributes 363 } // end Code 364 } // Attributes 365 } 366 ; 367 { // method 368 0x0008; // access 369 #20; // name_index 370 #12; // descriptor_index 371 [] { // Attributes 372 Attr(#18) { // Code 373 1; // max_stack 374 0; // max_locals 375 Bytes[]{ 376 0x03B3000DB1; 377 } 378 [] { // Traps 379 } // end Traps 380 [] { // Attributes 381 Attr(#19) { // LineNumberTable 382 [] { // line_number_table 383 0 2; 384 } 385 } // end LineNumberTable 386 } // Attributes 387 } // end Code 388 } // Attributes 389 } 390 } // Methods 391 392 [] { // Attributes 393 Attr(#21) { // SourceFile 394 #22; 395 } // end SourceFile 396 } // Attributes 397 } // end class StrictNotFinal 398 399 // A value class declaring a field without ACC_STATIC nor ACC_STRICT 400 // 401 class NotStaticNotStrict { 402 0xCAFEBABE; 403 65535; // minor version 404 67; // version 405 [] { // Constant Pool 406 ; // first element is empty 407 Field #2 #3; // #1 408 class #4; // #2 409 NameAndType #5 #6; // #3 410 Utf8 "NotStaticNotStrict"; // #4 411 Utf8 "i"; // #5 412 Utf8 "I"; // #6 413 Method #8 #9; // #7 414 class #10; // #8 415 NameAndType #11 #12; // #9 416 Utf8 "java/lang/Object"; // #10 417 Utf8 "<init>"; // #11 418 Utf8 "()V"; // #12 419 Field #2 #14; // #13 420 NameAndType #15 #6; // #14 421 Utf8 "si"; // #15 422 Utf8 "ConstantValue"; // #16 423 int 0x00000000; // #17 424 Utf8 "Code"; // #18 425 Utf8 "LineNumberTable"; // #19 426 Utf8 "<clinit>"; // #20 427 Utf8 "SourceFile"; // #21 428 Utf8 "NotStaticNotStrict.java"; // #22 429 } // Constant Pool 430 431 0x0011; // access 432 #2;// this_cpx 433 #8;// super_cpx 434 435 [] { // Interfaces 436 } // Interfaces 437 438 [] { // Fields 439 { // field 440 0x0008; // access 441 #15; // name_index 442 #6; // descriptor_index 443 [] { // Attributes 444 } // Attributes 445 } 446 ; 447 { // field 448 0x0010; // access 449 #5; // name_index 450 #6; // descriptor_index 451 [] { // Attributes 452 Attr(#16) { // ConstantValue 453 #17; 454 } // end ConstantValue 455 } // Attributes 456 } 457 } // Fields 458 459 [] { // Methods 460 { // method 461 0x0001; // access 462 #11; // name_index 463 #12; // descriptor_index 464 [] { // Attributes 465 Attr(#18) { // Code 466 2; // max_stack 467 1; // max_locals 468 Bytes[]{ 469 0x2A03B500012AB700; 470 0x07B1; 471 } 472 [] { // Traps 473 } // end Traps 474 [] { // Attributes 475 Attr(#19) { // LineNumberTable 476 [] { // line_number_table 477 0 3; 478 5 1; 479 9 3; 480 } 481 } // end LineNumberTable 482 } // Attributes 483 } // end Code 484 } // Attributes 485 } 486 ; 487 { // method 488 0x0008; // access 489 #20; // name_index 490 #12; // descriptor_index 491 [] { // Attributes 492 Attr(#18) { // Code 493 1; // max_stack 494 0; // max_locals 495 Bytes[]{ 496 0x03B3000DB1; 497 } 498 [] { // Traps 499 } // end Traps 500 [] { // Attributes 501 Attr(#19) { // LineNumberTable 502 [] { // line_number_table 503 0 2; 504 } 505 } // end LineNumberTable 506 } // Attributes 507 } // end Code 508 } // Attributes 509 } 510 } // Methods 511 512 [] { // Attributes 513 Attr(#21) { // SourceFile 514 #22; 515 } // end SourceFile 516 } // Attributes 517 } // end class NotStaticNotStrict