1 /*
   2  * Copyright (c) 2017, 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 // Class containing duplicate Signature attributes.  Loading it should cause a
  25 // ClassFormatError exception.
  26 class DupClassSigAttrs {
  27   0xCAFEBABE;
  28   0; // minor version
  29   53; // version
  30   [33] { // Constant Pool
  31     ; // first element is empty
  32     Method #6 #17; // #1     at 0x0A
  33     Field #18 #19; // #2     at 0x0F
  34     String #20; // #3     at 0x14
  35     Method #21 #22; // #4     at 0x17
  36     class #23; // #5     at 0x1C
  37     class #24; // #6     at 0x1F
  38     Utf8 "<init>"; // #7     at 0x22
  39     Utf8 "()V"; // #8     at 0x2B
  40     Utf8 "Code"; // #9     at 0x31
  41     Utf8 "LineNumberTable"; // #10     at 0x38
  42     Utf8 "main"; // #11     at 0x4A
  43     Utf8 "([Ljava/lang/String;)V"; // #12     at 0x51
  44     Utf8 "Exceptions"; // #13     at 0x6A
  45     class #25; // #14     at 0x77
  46     Utf8 "SourceFile"; // #15     at 0x7A
  47     Utf8 "DupClassSigAttrs.java"; // #16     at 0x87
  48     NameAndType #7 #8; // #17     at 0x9F
  49     class #26; // #18     at 0xA4
  50     NameAndType #27 #28; // #19     at 0xA7
  51     Utf8 "hi"; // #20     at 0xAC
  52     class #29; // #21     at 0xB1
  53     NameAndType #30 #31; // #22     at 0xB4
  54     Utf8 "DupClassSigAttrs"; // #23     at 0xB9
  55     Utf8 "java/lang/Object"; // #24     at 0xCC
  56     Utf8 "java/lang/Throwable"; // #25     at 0xDF
  57     Utf8 "java/lang/System"; // #26     at 0xF5
  58     Utf8 "out"; // #27     at 0x0108
  59     Utf8 "Ljava/io/PrintStream;"; // #28     at 0x010E
  60     Utf8 "java/io/PrintStream"; // #29     at 0x0126
  61     Utf8 "println"; // #30     at 0x013C
  62     Utf8 "(Ljava/lang/String;)V"; // #31     at 0x0146
  63     Utf8 "Signature"; // #32     at 0x015E
  64   } // Constant Pool
  65 
  66   0x0021; // access
  67   #5;// this_cpx
  68   #6;// super_cpx
  69 
  70   [0] { // Interfaces
  71   } // Interfaces
  72 
  73   [0] { // fields
  74   } // fields
  75 
  76   [2] { // methods
  77     { // Member at 0x0176
  78       0x0001; // access
  79       #7; // name_cpx
  80       #8; // sig_cpx
  81       [1] { // Attributes
  82         Attr(#9, 29) { // Code at 0x017E
  83           1; // max_stack
  84           1; // max_locals
  85           Bytes[5]{
  86             0x2AB70001B1;
  87           };
  88           [0] { // Traps
  89           } // end Traps
  90           [1] { // Attributes
  91             Attr(#10, 6) { // LineNumberTable at 0x0195
  92               [1] { // LineNumberTable
  93                 0  1; //  at 0x01A1
  94               }
  95             } // end LineNumberTable
  96           } // Attributes
  97         } // end Code
  98       } // Attributes
  99     } // Member
 100     ;
 101     { // Member at 0x01A1
 102       0x0009; // access
 103       #11; // name_cpx
 104       #12; // sig_cpx
 105       [2] { // Attributes
 106         Attr(#9, 37) { // Code at 0x01A9
 107           2; // max_stack
 108           1; // max_locals
 109           Bytes[9]{
 110             0xB200021203B60004;
 111             0xB1;
 112           };
 113           [0] { // Traps
 114           } // end Traps
 115           [1] { // Attributes
 116             Attr(#10, 10) { // LineNumberTable at 0x01C4
 117               [2] { // LineNumberTable
 118                 0  4; //  at 0x01D0
 119                 8  5; //  at 0x01D4
 120               }
 121             } // end LineNumberTable
 122           } // Attributes
 123         } // end Code
 124         ;
 125         Attr(#13, 4) { // Exceptions at 0x01D4
 126           [1] { // Exceptions
 127             #14; //  at 0x01DE
 128           }
 129         } // end Exceptions
 130       } // Attributes
 131     } // Member
 132   } // methods
 133 
 134   [3] { // Attributes
 135     Attr(#15, 2) { // SourceFile at 0x01E0
 136       #16;
 137     } // end SourceFile
 138     ;
 139     Attr(#32, 2) { // Signature at 0x01E8
 140       #16;
 141     } // end Signature
 142     ;
 143     Attr(#32, 2) { // *** Duplicate *** Signature at 0x01F0
 144       #16;
 145     } // end Signature
 146   } // Attributes
 147 } // end class DupClassSigAttrs
 148 
 149 
 150 // Class containing a method with duplicate Signature attributes.  Loading it
 151 // should cause a ClassFormatError exception.
 152 class DupMthSigAttrs {
 153   0xCAFEBABE;
 154   0; // minor version
 155   53; // version
 156   [33] { // Constant Pool
 157     ; // first element is empty
 158     Method #6 #17; // #1     at 0x0A
 159     Field #18 #19; // #2     at 0x0F
 160     String #20; // #3     at 0x14
 161     Method #21 #22; // #4     at 0x17
 162     class #23; // #5     at 0x1C
 163     class #24; // #6     at 0x1F
 164     Utf8 "<init>"; // #7     at 0x22
 165     Utf8 "()V"; // #8     at 0x2B
 166     Utf8 "Code"; // #9     at 0x31
 167     Utf8 "LineNumberTable"; // #10     at 0x38
 168     Utf8 "main"; // #11     at 0x4A
 169     Utf8 "([Ljava/lang/String;)V"; // #12     at 0x51
 170     Utf8 "Exceptions"; // #13     at 0x6A
 171     class #25; // #14     at 0x77
 172     Utf8 "SourceFile"; // #15     at 0x7A
 173     Utf8 "DupMthSigAttrs.java"; // #16     at 0x87
 174     NameAndType #7 #8; // #17     at 0x9D
 175     class #26; // #18     at 0xA2
 176     NameAndType #27 #28; // #19     at 0xA5
 177     Utf8 "hi"; // #20     at 0xAA
 178     class #29; // #21     at 0xAF
 179     NameAndType #30 #31; // #22     at 0xB2
 180     Utf8 "DupMthSigAttrs"; // #23     at 0xB7
 181     Utf8 "java/lang/Object"; // #24     at 0xC8
 182     Utf8 "java/lang/Throwable"; // #25     at 0xDB
 183     Utf8 "java/lang/System"; // #26     at 0xF1
 184     Utf8 "out"; // #27     at 0x0104
 185     Utf8 "Ljava/io/PrintStream;"; // #28     at 0x010A
 186     Utf8 "java/io/PrintStream"; // #29     at 0x0122
 187     Utf8 "println"; // #30     at 0x0138
 188     Utf8 "(Ljava/lang/String;)V"; // #31     at 0x0142
 189     Utf8 "Signature"; // #32     at 0x015A
 190   } // Constant Pool
 191 
 192   0x0021; // access
 193   #5;// this_cpx
 194   #6;// super_cpx
 195 
 196   [0] { // Interfaces
 197   } // Interfaces
 198 
 199   [0] { // fields
 200   } // fields
 201 
 202   [2] { // methods
 203     { // Member at 0x0172
 204       0x0001; // access
 205       #7; // name_cpx
 206       #8; // sig_cpx
 207       [1] { // Attributes
 208         Attr(#9, 29) { // Code at 0x017A
 209           1; // max_stack
 210           1; // max_locals
 211           Bytes[5]{
 212             0x2AB70001B1;
 213           };
 214           [0] { // Traps
 215           } // end Traps
 216           [1] { // Attributes
 217             Attr(#10, 6) { // LineNumberTable at 0x0191
 218               [1] { // LineNumberTable
 219                 0  1; //  at 0x019D
 220               }
 221             } // end LineNumberTable
 222           } // Attributes
 223         } // end Code
 224       } // Attributes
 225     } // Member
 226     ;
 227     { // Member at 0x019D
 228       0x0009; // access
 229       #11; // name_cpx
 230       #12; // sig_cpx
 231       [4] { // Attributes
 232         Attr(#9, 37) { // Code at 0x01A5
 233           2; // max_stack
 234           1; // max_locals
 235           Bytes[9]{
 236             0xB200021203B60004;
 237             0xB1;
 238           };
 239           [0] { // Traps
 240           } // end Traps
 241           [1] { // Attributes
 242             Attr(#10, 10) { // LineNumberTable at 0x01C0
 243               [2] { // LineNumberTable
 244                 0  4; //  at 0x01CC
 245                 8  5; //  at 0x01D0
 246               }
 247             } // end LineNumberTable
 248           } // Attributes
 249         } // end Code
 250         ;
 251         Attr(#32, 2) { // Signature at 0x01D0
 252           #16;
 253         } // end Signature
 254         ;
 255         Attr(#13, 4) { // Exceptions at 0x01D8
 256           [1] { // Exceptions
 257             #14; //  at 0x01E2
 258           }
 259         } // end Exceptions
 260         ;
 261         Attr(#32, 2) { // *** Duplicate *** Signature at 0x01E2
 262           #16;
 263         } // end Signature
 264       } // Attributes
 265     } // Member
 266   } // methods
 267 
 268   [1] { // Attributes
 269     Attr(#15, 2) { // SourceFile at 0x01EC
 270       #16;
 271     } // end SourceFile
 272   } // Attributes
 273 } // end class DupMthSigAttrs
 274 
 275 
 276 // Class containing a field with duplicate Signature attributes.  Loading it
 277 // should cause a ClassFormatError exception.
 278 class DupFldSigAttrs {
 279   0xCAFEBABE;
 280   0; // minor version
 281   53; // version
 282   [42] { // Constant Pool
 283     ; // first element is empty
 284     Method #9 #23; // #1     at 0x0A
 285     Field #24 #25; // #2     at 0x0F
 286     Field #8 #26; // #3     at 0x14
 287     Method #27 #28; // #4     at 0x19
 288     class #29; // #5     at 0x1E
 289     String #30; // #6     at 0x21
 290     Method #5 #31; // #7     at 0x24
 291     class #32; // #8     at 0x29
 292     class #33; // #9     at 0x2C
 293     Utf8 "str"; // #10     at 0x2F
 294     Utf8 "Ljava/lang/String;"; // #11     at 0x35
 295     Utf8 "<init>"; // #12     at 0x4A
 296     Utf8 "()V"; // #13     at 0x53
 297     Utf8 "Code"; // #14     at 0x59
 298     Utf8 "LineNumberTable"; // #15     at 0x60
 299     Utf8 "main"; // #16     at 0x72
 300     Utf8 "([Ljava/lang/String;)V"; // #17     at 0x79
 301     Utf8 "Exceptions"; // #18     at 0x92
 302     class #34; // #19     at 0x9F
 303     Utf8 "<clinit>"; // #20     at 0xA2
 304     Utf8 "SourceFile"; // #21     at 0xAD
 305     Utf8 "DupFldSigAttrs.java"; // #22     at 0xBA
 306     NameAndType #12 #13; // #23     at 0xD0
 307     class #35; // #24     at 0xD5
 308     NameAndType #36 #37; // #25     at 0xD8
 309     NameAndType #10 #11; // #26     at 0xDD
 310     class #38; // #27     at 0xE2
 311     NameAndType #39 #40; // #28     at 0xE5
 312     Utf8 "java/lang/String"; // #29     at 0xEA
 313     Utf8 "Hi"; // #30     at 0xFD
 314     NameAndType #12 #40; // #31     at 0x0102
 315     Utf8 "DupFldSigAttrs"; // #32     at 0x0107
 316     Utf8 "java/lang/Object"; // #33     at 0x0118
 317     Utf8 "java/lang/Throwable"; // #34     at 0x012B
 318     Utf8 "java/lang/System"; // #35     at 0x0141
 319     Utf8 "out"; // #36     at 0x0154
 320     Utf8 "Ljava/io/PrintStream;"; // #37     at 0x015A
 321     Utf8 "java/io/PrintStream"; // #38     at 0x0172
 322     Utf8 "println"; // #39     at 0x0188
 323     Utf8 "(Ljava/lang/String;)V"; // #40     at 0x0192
 324     Utf8 "Signature"; // #41     at 0x01AA
 325   } // Constant Pool
 326 
 327   0x0021; // access
 328   #8;// this_cpx
 329   #9;// super_cpx
 330 
 331   [0] { // Interfaces
 332   } // Interfaces
 333 
 334   [1] { // fields
 335     { // Member at 0x01C0
 336       0x0008; // access
 337       #10; // name_cpx
 338       #11; // sig_cpx
 339       [2] { // Attributes
 340         Attr(#41, 2) { // Signature at 0x01C8
 341           #16;
 342         } // end Signature
 343         ;
 344         Attr(#41, 2) { // *** Duplicate *** Signature at 0x01D0
 345           #16;
 346         } // end Signature
 347       } // Attributes
 348     } // Member
 349   } // fields
 350 
 351   [3] { // methods
 352     { // Member at 0x01DA
 353       0x0001; // access
 354       #12; // name_cpx
 355       #13; // sig_cpx
 356       [1] { // Attributes
 357         Attr(#14, 29) { // Code at 0x01E2
 358           1; // max_stack
 359           1; // max_locals
 360           Bytes[5]{
 361             0x2AB70001B1;
 362           };
 363           [0] { // Traps
 364           } // end Traps
 365           [1] { // Attributes
 366             Attr(#15, 6) { // LineNumberTable at 0x01F9
 367               [1] { // LineNumberTable
 368                 0  1; //  at 0x0205
 369               }
 370             } // end LineNumberTable
 371           } // Attributes
 372         } // end Code
 373       } // Attributes
 374     } // Member
 375     ;
 376     { // Member at 0x0205
 377       0x0009; // access
 378       #16; // name_cpx
 379       #17; // sig_cpx
 380       [2] { // Attributes
 381         Attr(#14, 38) { // Code at 0x020D
 382           2; // max_stack
 383           1; // max_locals
 384           Bytes[10]{
 385             0xB20002B20003B600;
 386             0x04B1;
 387           };
 388           [0] { // Traps
 389           } // end Traps
 390           [1] { // Attributes
 391             Attr(#15, 10) { // LineNumberTable at 0x0229
 392               [2] { // LineNumberTable
 393                 0  6; //  at 0x0235
 394                 9  7; //  at 0x0239
 395               }
 396             } // end LineNumberTable
 397           } // Attributes
 398         } // end Code
 399         ;
 400         Attr(#18, 4) { // Exceptions at 0x0239
 401           [1] { // Exceptions
 402             #19; //  at 0x0243
 403           }
 404         } // end Exceptions
 405       } // Attributes
 406     } // Member
 407     ;
 408     { // Member at 0x0243
 409       0x0008; // access
 410       #20; // name_cpx
 411       #13; // sig_cpx
 412       [1] { // Attributes
 413         Attr(#14, 37) { // Code at 0x024B
 414           3; // max_stack
 415           0; // max_locals
 416           Bytes[13]{
 417             0xBB0005591206B700;
 418             0x07B30003B1;
 419           };
 420           [0] { // Traps
 421           } // end Traps
 422           [1] { // Attributes
 423             Attr(#15, 6) { // LineNumberTable at 0x026A
 424               [1] { // LineNumberTable
 425                 0  3; //  at 0x0276
 426               }
 427             } // end LineNumberTable
 428           } // Attributes
 429         } // end Code
 430       } // Attributes
 431     } // Member
 432   } // methods
 433 
 434   [1] { // Attributes
 435     Attr(#21, 2) { // SourceFile at 0x0278
 436       #22;
 437     } // end SourceFile
 438   } // Attributes
 439 } // end class DupFldSigAttrs
 440 
 441 
 442 // Class containing a Signature attribute and a field and methods with Signature
 443 // attributes.  Since neither the class nor any of its fields or methods have
 444 // duplicate Signature attributes, loading this class should not cause a
 445 // ClassFormatError exception.
 446 class OkaySigAttrs {
 447   0xCAFEBABE;
 448   0; // minor version
 449   53; // version
 450   [42] { // Constant Pool
 451     ; // first element is empty
 452     Method #9 #23; // #1     at 0x0A
 453     Field #24 #25; // #2     at 0x0F
 454     Field #8 #26; // #3     at 0x14
 455     Method #27 #28; // #4     at 0x19
 456     class #29; // #5     at 0x1E
 457     String #30; // #6     at 0x21
 458     Method #5 #31; // #7     at 0x24
 459     class #32; // #8     at 0x29
 460     class #33; // #9     at 0x2C
 461     Utf8 "str"; // #10     at 0x2F
 462     Utf8 "Ljava/lang/String;"; // #11     at 0x35
 463     Utf8 "<init>"; // #12     at 0x4A
 464     Utf8 "()V"; // #13     at 0x53
 465     Utf8 "Code"; // #14     at 0x59
 466     Utf8 "LineNumberTable"; // #15     at 0x60
 467     Utf8 "main"; // #16     at 0x72
 468     Utf8 "([Ljava/lang/String;)V"; // #17     at 0x79
 469     Utf8 "Exceptions"; // #18     at 0x92
 470     class #34; // #19     at 0x9F
 471     Utf8 "<clinit>"; // #20     at 0xA2
 472     Utf8 "SourceFile"; // #21     at 0xAD
 473     Utf8 "OkaySigAttrs.java"; // #22     at 0xBA
 474     NameAndType #12 #13; // #23     at 0xCE
 475     class #35; // #24     at 0xD3
 476     NameAndType #36 #37; // #25     at 0xD6
 477     NameAndType #10 #11; // #26     at 0xDB
 478     class #38; // #27     at 0xE0
 479     NameAndType #39 #40; // #28     at 0xE3
 480     Utf8 "java/lang/String"; // #29     at 0xE8
 481     Utf8 "Hi"; // #30     at 0xFB
 482     NameAndType #12 #40; // #31     at 0x0100
 483     Utf8 "OkaySigAttrs"; // #32     at 0x0105
 484     Utf8 "java/lang/Object"; // #33     at 0x0114
 485     Utf8 "java/lang/Throwable"; // #34     at 0x0127
 486     Utf8 "java/lang/System"; // #35     at 0x013D
 487     Utf8 "out"; // #36     at 0x0150
 488     Utf8 "Ljava/io/PrintStream;"; // #37     at 0x0156
 489     Utf8 "java/io/PrintStream"; // #38     at 0x016E
 490     Utf8 "println"; // #39     at 0x0184
 491     Utf8 "(Ljava/lang/String;)V"; // #40     at 0x018E
 492     Utf8 "Signature"; // #41     at 0x01A6
 493   } // Constant Pool
 494 
 495   0x0021; // access
 496   #8;// this_cpx
 497   #9;// super_cpx
 498 
 499   [0] { // Interfaces
 500   } // Interfaces
 501 
 502   [1] { // fields
 503     { // Member at 0x01BC
 504       0x0008; // access
 505       #10; // name_cpx
 506       #11; // sig_cpx
 507       [1] { // Attributes
 508         Attr(#41, 2) { // Signature at 0x01C4
 509           #16;
 510         } // end Signature
 511       } // Attributes
 512     } // Member
 513   } // fields
 514 
 515   [3] { // methods
 516     { // Member at 0x01CE
 517       0x0001; // access
 518       #12; // name_cpx
 519       #13; // sig_cpx
 520       [2] { // Attributes
 521         Attr(#14, 29) { // Code at 0x01D6
 522           1; // max_stack
 523           1; // max_locals
 524           Bytes[5]{
 525             0x2AB70001B1;
 526           };
 527           [0] { // Traps
 528           } // end Traps
 529           [1] { // Attributes
 530             Attr(#15, 6) { // LineNumberTable at 0x01ED
 531               [1] { // LineNumberTable
 532                 0  1; //  at 0x01F9
 533               }
 534             } // end LineNumberTable
 535           } // Attributes
 536         } // end Code
 537         ;
 538         Attr(#41, 2) { // Signature at 0x01F9
 539           #16;
 540         } // end Signature
 541       } // Attributes
 542     } // Member
 543     ;
 544     { // Member at 0x0201
 545       0x0009; // access
 546       #16; // name_cpx
 547       #17; // sig_cpx
 548       [3] { // Attributes
 549         Attr(#14, 38) { // Code at 0x0209
 550           2; // max_stack
 551           1; // max_locals
 552           Bytes[10]{
 553             0xB20002B20003B600;
 554             0x04B1;
 555           };
 556           [0] { // Traps
 557           } // end Traps
 558           [1] { // Attributes
 559             Attr(#15, 10) { // LineNumberTable at 0x0225
 560               [2] { // LineNumberTable
 561                 0  6; //  at 0x0231
 562                 9  7; //  at 0x0235
 563               }
 564             } // end LineNumberTable
 565           } // Attributes
 566         } // end Code
 567         ;
 568         Attr(#41, 2) { // Signature at 0x0235
 569           #16;
 570         } // end Signature
 571         ;
 572         Attr(#18, 4) { // Exceptions at 0x023D
 573           [1] { // Exceptions
 574             #19; //  at 0x0247
 575           }
 576         } // end Exceptions
 577       } // Attributes
 578     } // Member
 579     ;
 580     { // Member at 0x0247
 581       0x0008; // access
 582       #20; // name_cpx
 583       #13; // sig_cpx
 584       [1] { // Attributes
 585         Attr(#14, 37) { // Code at 0x024F
 586           3; // max_stack
 587           0; // max_locals
 588           Bytes[13]{
 589             0xBB0005591206B700;
 590             0x07B30003B1;
 591           };
 592           [0] { // Traps
 593           } // end Traps
 594           [1] { // Attributes
 595             Attr(#15, 6) { // LineNumberTable at 0x026E
 596               [1] { // LineNumberTable
 597                 0  3; //  at 0x027A
 598               }
 599             } // end LineNumberTable
 600           } // Attributes
 601         } // end Code
 602       } // Attributes
 603     } // Member
 604   } // methods
 605 
 606   [2] { // Attributes
 607     Attr(#21, 2) { // SourceFile at 0x027C
 608       #22;
 609     } // end SourceFile
 610     ;
 611     Attr(#41, 2) { // Signature at 0x0284
 612       #16;
 613     } // end Signature
 614   } // Attributes
 615 } // end class OkaySigAttrs