1 /*
   2  * Copyright (c) 2018, 2019, 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 not thrown when trying to pass a value
  26 // type array when the formal parameter is an array of java.lang.Object.
  27 //
  28 // // Java program emulating the jcod contents.
  29 // public value final class NoArrayCov {
  30 //     final int x;
  31 //     final int y;
  32 //
  33 //     private NoArrayCov() {
  34 //         x = 0;
  35 //         y = 0;
  36 //     }
  37 //
  38 //     public int getX() { return x; }
  39 //     public int getY() { return y; }
  40 //
  41 //     public String toString() {
  42 //         return "NoArrayCov: x=" + getX() + " y=" + getY();
  43 //     }
  44 //
  45 //     public void objArray(Object[] oArr) {
  46 //         System.out.println("In objArray");
  47 //     }
  48 //
  49 //     public static NoArrayCov createNoArrayCov(int x, int y) {
  50 //         NoArrayCov p = NoArrayCov.default;
  51 //         p = __WithField(p.x, x);
  52 //         p = __WithField(p.y, y);
  53 //         return p;
  54 //     }
  55 //
  56 //     public static void main(String[] args) {
  57 //         NoArrayCov a = createNoArrayCov(3, 4);
  58 //         NoArrayCov b = createNoArrayCov(2, 4);
  59 //         NoArrayCov pa[] = new NoArrayCov[2];
  60 //         pa[0] = a;
  61 //         pa[1] = b;
  62 //         a.objArray(pa); // Should not cause VerifyError exception !!!
  63 //     }
  64 // }
  65 
  66 class NoArrayCov {
  67   0xCAFEBABE;
  68   0; // minor version
  69   57; // version
  70   [98] { // Constant Pool
  71     ; // first element is empty
  72     Method #17 #47; // #1     at 0x0A
  73     Field #10 #48; // #2     at 0x0F
  74     Field #10 #49; // #3     at 0x14
  75     Method #10 #50; // #4     at 0x19
  76     Method #10 #51; // #5     at 0x1E
  77     InvokeDynamic 0s #55; // #6     at 0x23
  78     Field #56 #57; // #7     at 0x28
  79     String #58; // #8     at 0x2D
  80     Method #59 #60; // #9     at 0x30
  81     class #33; // #10     at 0x35
  82     Method #10 #61; // #11     at 0x38
  83     class #62; // #12     at 0x3D
  84     Method #10 #63; // #13     at 0x40
  85     InvokeDynamic 1s #65; // #14     at 0x45
  86     InvokeDynamic 1s #66; // #15     at 0x4A
  87     InvokeDynamic 1s #67; // #16     at 0x4F
  88     class #68; // #17     at 0x54
  89     Utf8 "x"; // #18     at 0x57
  90     Utf8 "I"; // #19     at 0x5B
  91     Utf8 "y"; // #20     at 0x5F
  92     Utf8 "<init>"; // #21     at 0x63
  93     Utf8 "()V"; // #22     at 0x6C
  94     Utf8 "Code"; // #23     at 0x72
  95     Utf8 "LineNumberTable"; // #24     at 0x79
  96     Utf8 "getX"; // #25     at 0x8B
  97     Utf8 "()I"; // #26     at 0x92
  98     Utf8 "getY"; // #27     at 0x98
  99     Utf8 "toString"; // #28     at 0x9F
 100     Utf8 "()Ljava/lang/String;"; // #29     at 0xAA
 101     Utf8 "objArray"; // #30     at 0xC1
 102     Utf8 "([Ljava/lang/Object;)V"; // #31     at 0xCC
 103     Utf8 "createNoArrayCov"; // #32     at 0xE5
 104     Utf8 "NoArrayCov"; // #33     at 0xF8
 105     Utf8 "ValueTypes"; // #34     at 0x0105
 106     Utf8 "(II)QNoArrayCov;"; // #35     at 0x0112
 107     Utf8 "main"; // #36     at 0x0125
 108     Utf8 "([Ljava/lang/String;)V"; // #37     at 0x012C
 109     Utf8 "hashCode"; // #38     at 0x0145
 110     Utf8 "equals"; // #39     at 0x0150
 111     Utf8 "(Ljava/lang/Object;)Z"; // #40     at 0x0159
 112     Utf8 "longHashCode"; // #41     at 0x0171
 113     Utf8 "()J"; // #42     at 0x0180
 114     Utf8 "$makeValue$"; // #43     at 0x0186
 115     Utf8 "()QNoArrayCov;"; // #44     at 0x0194
 116     Utf8 "SourceFile"; // #45     at 0x01A5
 117     Utf8 "NoArrayCov.java"; // #46     at 0x01B2
 118     NameAndType #21 #22; // #47     at 0x01C4
 119     NameAndType #18 #19; // #48     at 0x01C9
 120     NameAndType #20 #19; // #49     at 0x01CE
 121     NameAndType #25 #26; // #50     at 0x01D3
 122     NameAndType #27 #26; // #51     at 0x01D8
 123     Utf8 "BootstrapMethods"; // #52     at 0x01DD
 124     MethodHandle 6b #69; // #53     at 0x01F0
 125     String #70; // #54     at 0x01F4
 126     NameAndType #71 #72; // #55     at 0x01F7
 127     class #73; // #56     at 0x01FC
 128     NameAndType #74 #75; // #57     at 0x01FF
 129     Utf8 "In objArray"; // #58     at 0x0204
 130     class #76; // #59     at 0x0212
 131     NameAndType #77 #78; // #60     at 0x0215
 132     NameAndType #32 #35; // #61     at 0x021A
 133     Utf8 "QNoArrayCov;"; // #62     at 0x021F
 134     NameAndType #30 #31; // #63     at 0x022E
 135     MethodHandle 6b #79; // #64     at 0x0233
 136     NameAndType #38 #80; // #65     at 0x0237
 137     NameAndType #39 #81; // #66     at 0x023C
 138     NameAndType #41 #82; // #67     at 0x0241
 139     Utf8 "java/lang/Object"; // #68     at 0x0246
 140     Method #83 #84; // #69     at 0x0259
 141     Utf8 "NoArrayCov: x= y="; // #70     at 0x025E
 142     Utf8 "makeConcatWithConstants"; // #71     at 0x0274
 143     Utf8 "(II)Ljava/lang/String;"; // #72     at 0x028E
 144     Utf8 "java/lang/System"; // #73     at 0x02A7
 145     Utf8 "out"; // #74     at 0x02BA
 146     Utf8 "Ljava/io/PrintStream;"; // #75     at 0x02C0
 147     Utf8 "java/io/PrintStream"; // #76     at 0x02D8
 148     Utf8 "println"; // #77     at 0x02EE
 149     Utf8 "(Ljava/lang/String;)V"; // #78     at 0x02F8
 150     Method #85 #86; // #79     at 0x0310
 151     Utf8 "(Ljava/lang/Object;)I"; // #80     at 0x0315
 152     Utf8 "(Ljava/lang/Object;Ljava/lang/Object;)Z"; // #81     at 0x032D
 153     Utf8 "(Ljava/lang/Object;)J"; // #82     at 0x0357
 154     class #87; // #83     at 0x036F
 155     NameAndType #71 #91; // #84     at 0x0372
 156     class #92; // #85     at 0x0377
 157     NameAndType #93 #94; // #86     at 0x037A
 158     Utf8 "java/lang/invoke/StringConcatFactory"; // #87     at 0x037F
 159     class #96; // #88     at 0x03A6
 160     Utf8 "Lookup"; // #89     at 0x03A9
 161     Utf8 "InnerClasses"; // #90     at 0x03B2
 162     Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;"; // #91     at 0x03C1
 163     Utf8 "java/lang/invoke/ValueBootstrapMethods"; // #92     at 0x045C
 164     Utf8 "makeBootstrapMethod"; // #93     at 0x0485
 165     Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; // #94     at 0x049B
 166     class #97; // #95     at 0x0511
 167     Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #96     at 0x0514
 168     Utf8 "java/lang/invoke/MethodHandles"; // #97     at 0x053C
 169   } // Constant Pool
 170 
 171   0x0131; // access [ ACC_PUBLIC ACC_SUPER ACC_FINAL ]
 172   #10;// this_cpx
 173   #17;// super_cpx
 174 
 175   [0] { // Interfaces
 176   } // Interfaces
 177 
 178   [2] { // fields
 179     { // Member at 0x0567
 180       0x0010; // access
 181       #18; // name_cpx
 182       #19; // sig_cpx
 183       [0] { // Attributes
 184       } // Attributes
 185     } // Member
 186     ;
 187     { // Member at 0x056F
 188       0x0010; // access
 189       #20; // name_cpx
 190       #19; // sig_cpx
 191       [0] { // Attributes
 192       } // Attributes
 193     } // Member
 194   } // fields
 195 
 196   [11] { // methods
 197     { // Member at 0x0579
 198       0x0002; // access
 199       #21; // name_cpx
 200       #22; // sig_cpx
 201       [1] { // Attributes
 202         Attr(#23, 29) { // Code at 0x0581
 203           1; // max_stack
 204           1; // max_locals
 205           Bytes[5]{
 206             0x2AB70001B1;
 207           };
 208           [0] { // Traps
 209           } // end Traps
 210           [1] { // Attributes
 211             Attr(#24, 6) { // LineNumberTable at 0x0598
 212               [1] { // LineNumberTable
 213                 0  28; //  at 0x05A4
 214               }
 215             } // end LineNumberTable
 216           } // Attributes
 217         } // end Code
 218       } // Attributes
 219     } // Member
 220     ;
 221     { // Member at 0x05A4
 222       0x0001; // access
 223       #25; // name_cpx
 224       #26; // sig_cpx
 225       [1] { // Attributes
 226         Attr(#23, 29) { // Code at 0x05AC
 227           1; // max_stack
 228           1; // max_locals
 229           Bytes[5]{
 230             0x2AB40002AC;
 231           };
 232           [0] { // Traps
 233           } // end Traps
 234           [1] { // Attributes
 235             Attr(#24, 6) { // LineNumberTable at 0x05C3
 236               [1] { // LineNumberTable
 237                 0  33; //  at 0x05CF
 238               }
 239             } // end LineNumberTable
 240           } // Attributes
 241         } // end Code
 242       } // Attributes
 243     } // Member
 244     ;
 245     { // Member at 0x05CF
 246       0x0001; // access
 247       #27; // name_cpx
 248       #26; // sig_cpx
 249       [1] { // Attributes
 250         Attr(#23, 29) { // Code at 0x05D7
 251           1; // max_stack
 252           1; // max_locals
 253           Bytes[5]{
 254             0x2AB40003AC;
 255           };
 256           [0] { // Traps
 257           } // end Traps
 258           [1] { // Attributes
 259             Attr(#24, 6) { // LineNumberTable at 0x05EE
 260               [1] { // LineNumberTable
 261                 0  34; //  at 0x05FA
 262               }
 263             } // end LineNumberTable
 264           } // Attributes
 265         } // end Code
 266       } // Attributes
 267     } // Member
 268     ;
 269     { // Member at 0x05FA
 270       0x0001; // access
 271       #28; // name_cpx
 272       #29; // sig_cpx
 273       [1] { // Attributes
 274         Attr(#23, 38) { // Code at 0x0602
 275           2; // max_stack
 276           1; // max_locals
 277           Bytes[14]{
 278             0x2AB600042AB60005;
 279             0xBA00060000B0;
 280           };
 281           [0] { // Traps
 282           } // end Traps
 283           [1] { // Attributes
 284             Attr(#24, 6) { // LineNumberTable at 0x0622
 285               [1] { // LineNumberTable
 286                 0  37; //  at 0x062E
 287               }
 288             } // end LineNumberTable
 289           } // Attributes
 290         } // end Code
 291       } // Attributes
 292     } // Member
 293     ;
 294     { // Member at 0x062E
 295       0x0001; // access
 296       #30; // name_cpx
 297       #31; // sig_cpx
 298       [1] { // Attributes
 299         Attr(#23, 37) { // Code at 0x0636
 300           2; // max_stack
 301           2; // max_locals
 302           Bytes[9]{
 303             0xB200071208B60009;
 304             0xB1;
 305           };
 306           [0] { // Traps
 307           } // end Traps
 308           [1] { // Attributes
 309             Attr(#24, 10) { // LineNumberTable at 0x0651
 310               [2] { // LineNumberTable
 311                 0  41; //  at 0x065D
 312                 8  42; //  at 0x0661
 313               }
 314             } // end LineNumberTable
 315           } // Attributes
 316         } // end Code
 317       } // Attributes
 318     } // Member
 319     ;
 320     { // Member at 0x0661
 321       0x0009; // access
 322       #32; // name_cpx
 323       #35; // sig_cpx
 324       [1] { // Attributes
 325         Attr(#23, 56) { // Code at 0x0669
 326           2; // max_stack
 327           3; // max_locals
 328           Bytes[20]{
 329             0xCB000A4D1A2C5FCC;
 330             0x00024D1B2C5FCC00;
 331             0x034D2CB0;
 332           };
 333           [0] { // Traps
 334           } // end Traps
 335           [1] { // Attributes
 336             Attr(#24, 18) { // LineNumberTable at 0x068F
 337               [4] { // LineNumberTable
 338                 0  45; //  at 0x069B
 339                 4  46; //  at 0x069F
 340                 11  47; //  at 0x06A3
 341                 18  48; //  at 0x06A7
 342               }
 343             } // end LineNumberTable
 344           } // Attributes
 345         } // end Code
 346       } // Attributes
 347     } // Member
 348     ;
 349     { // Member at 0x06A7
 350       0x0009; // access
 351       #36; // name_cpx
 352       #37; // sig_cpx
 353       [1] { // Attributes
 354         Attr(#23, 79) { // Code at 0x06AF
 355           3; // max_stack
 356           4; // max_locals
 357           Bytes[31]{
 358             0x0607B8000B4C0507;
 359             0xB8000B4D05BD000C;
 360             0x4E2D032B532D042C;
 361             0x532B2DB6000DB1;
 362           };
 363           [0] { // Traps
 364           } // end Traps
 365           [1] { // Attributes
 366             Attr(#24, 30) { // LineNumberTable at 0x06E0
 367               [7] { // LineNumberTable
 368                 0  52; //  at 0x06EC
 369                 6  53; //  at 0x06F0
 370                 12  54; //  at 0x06F4
 371                 17  55; //  at 0x06F8
 372                 21  56; //  at 0x06FC
 373                 25  57; //  at 0x0700
 374                 30  58; //  at 0x0704
 375               }
 376             } // end LineNumberTable
 377           } // Attributes
 378         } // end Code
 379       } // Attributes
 380     } // Member
 381     ;
 382     { // Member at 0x0704
 383       0x0011; // access
 384       #38; // name_cpx
 385       #26; // sig_cpx
 386       [1] { // Attributes
 387         Attr(#23, 31) { // Code at 0x070C
 388           1; // max_stack
 389           1; // max_locals
 390           Bytes[7]{
 391             0x2ABA000E0000AC;
 392           };
 393           [0] { // Traps
 394           } // end Traps
 395           [1] { // Attributes
 396             Attr(#24, 6) { // LineNumberTable at 0x0725
 397               [1] { // LineNumberTable
 398                 0  24; //  at 0x0731
 399               }
 400             } // end LineNumberTable
 401           } // Attributes
 402         } // end Code
 403       } // Attributes
 404     } // Member
 405     ;
 406     { // Member at 0x0731
 407       0x0011; // access
 408       #39; // name_cpx
 409       #40; // sig_cpx
 410       [1] { // Attributes
 411         Attr(#23, 32) { // Code at 0x0739
 412           2; // max_stack
 413           2; // max_locals
 414           Bytes[8]{
 415             0x2A2BBA000F0000AC;
 416           };
 417           [0] { // Traps
 418           } // end Traps
 419           [1] { // Attributes
 420             Attr(#24, 6) { // LineNumberTable at 0x0753
 421               [1] { // LineNumberTable
 422                 0  24; //  at 0x075F
 423               }
 424             } // end LineNumberTable
 425           } // Attributes
 426         } // end Code
 427       } // Attributes
 428     } // Member
 429     ;
 430     { // Member at 0x075F
 431       0x0011; // access
 432       #41; // name_cpx
 433       #42; // sig_cpx
 434       [1] { // Attributes
 435         Attr(#23, 31) { // Code at 0x0767
 436           2; // max_stack
 437           1; // max_locals
 438           Bytes[7]{
 439             0x2ABA00100000AD;
 440           };
 441           [0] { // Traps
 442           } // end Traps
 443           [1] { // Attributes
 444             Attr(#24, 6) { // LineNumberTable at 0x0780
 445               [1] { // LineNumberTable
 446                 0  24; //  at 0x078C
 447               }
 448             } // end LineNumberTable
 449           } // Attributes
 450         } // end Code
 451       } // Attributes
 452     } // Member
 453     ;
 454     { // Member at 0x078C
 455       0x100A; // access
 456       #43; // name_cpx
 457       #44; // sig_cpx
 458       [1] { // Attributes
 459         Attr(#23, 56) { // Code at 0x0794
 460           2; // max_stack
 461           1; // max_locals
 462           Bytes[20]{
 463             0xCB000A4B032A5FCC;
 464             0x00024B032A5FCC00;
 465             0x034B2AB0;
 466           };
 467           [0] { // Traps
 468           } // end Traps
 469           [1] { // Attributes
 470             Attr(#24, 18) { // LineNumberTable at 0x07BA
 471               [4] { // LineNumberTable
 472                 0  28; //  at 0x07C6
 473                 4  29; //  at 0x07CA
 474                 11  30; //  at 0x07CE
 475                 18  31; //  at 0x07D2
 476               }
 477             } // end LineNumberTable
 478           } // Attributes
 479         } // end Code
 480       } // Attributes
 481     } // Member
 482   } // methods
 483 
 484   [4] { // Attributes
 485     Attr(#45, 2) { // SourceFile at 0x07D4
 486       #46;
 487     } // end SourceFile
 488     ;
 489     Attr(#90, 10) { // InnerClasses at 0x07DC
 490       [1] { // InnerClasses
 491         #88 #95 #89 25; //  at 0x07EC
 492       }
 493     } // end InnerClasses
 494     ;
 495     Attr(#52, 12) { // BootstrapMethods at 0x07EC
 496       [2] { // bootstrap_methods
 497         {  //  bootstrap_method
 498           #53; // bootstrap_method_ref
 499           [1] { // bootstrap_arguments
 500             #54; //  at 0x07FA
 501           }  //  bootstrap_arguments
 502         }  //  bootstrap_method
 503         ;
 504         {  //  bootstrap_method
 505           #64; // bootstrap_method_ref
 506           [0] { // bootstrap_arguments
 507           }  //  bootstrap_arguments
 508         }  //  bootstrap_method
 509       }
 510     } // end BootstrapMethods
 511     ;
 512     Attr(#34, 4) { // ValueTypes at 0x07FE
 513       0x0001000A;
 514     } // end ValueTypes
 515   } // Attributes
 516 } // end class NoArrayCov