OpenJDK / valhalla / valhalla
changeset 53182:a86921211088 lworld
Summary: add new verifier tests for assignability checks of value types and arrays of value types.
Reviewed-by: dsimms
author | hseigel |
---|---|
date | Fri, 14 Dec 2018 13:15:10 -0500 |
parents | 36cc81c429f5 |
children | a0ee83b59f56 |
files | test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/NoArrayCov.jcod test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/NoArrayCovIntf.jcod test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/NoNullVT.jcod test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/VTAssignability.java test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/VerifierValueTypes.java |
diffstat | 5 files changed, 1577 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/NoArrayCov.jcod Fri Dec 14 13:15:10 2018 -0500 @@ -0,0 +1,516 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +// Test that a VerifyError exception is thrown when trying to pass a value +// type array when the formal parameter is an array of java.lang.Object. +// +// // Java program emulating the jcod contents. +// public value final class NoArrayCov { +// final int x; +// final int y; +// +// private NoArrayCov() { +// x = 0; +// y = 0; +// } +// +// public int getX() { return x; } +// public int getY() { return y; } +// +// public String toString() { +// return "NoArrayCov: x=" + getX() + " y=" + getY(); +// } +// +// public void objArray(Object[] oArr) { +// System.out.println("In objArray"); +// } +// +// public static NoArrayCov createNoArrayCov(int x, int y) { +// NoArrayCov p = NoArrayCov.default; +// p = __WithField(p.x, x); +// p = __WithField(p.y, y); +// return p; +// } +// +// public static void main(String[] args) { +// NoArrayCov a = createNoArrayCov(3, 4); +// NoArrayCov b = createNoArrayCov(2, 4); +// NoArrayCov pa[] = new NoArrayCov[2]; +// pa[0] = a; +// pa[1] = b; +// a.objArray(pa); // Should cause VerifyError exception !!! +// } +// } + +class NoArrayCov { + 0xCAFEBABE; + 0; // minor version + 56; // version + [98] { // Constant Pool + ; // first element is empty + Method #17 #47; // #1 at 0x0A + Field #10 #48; // #2 at 0x0F + Field #10 #49; // #3 at 0x14 + Method #10 #50; // #4 at 0x19 + Method #10 #51; // #5 at 0x1E + InvokeDynamic 0s #55; // #6 at 0x23 + Field #56 #57; // #7 at 0x28 + String #58; // #8 at 0x2D + Method #59 #60; // #9 at 0x30 + class #33; // #10 at 0x35 + Method #10 #61; // #11 at 0x38 + class #62; // #12 at 0x3D + Method #10 #63; // #13 at 0x40 + InvokeDynamic 1s #65; // #14 at 0x45 + InvokeDynamic 1s #66; // #15 at 0x4A + InvokeDynamic 1s #67; // #16 at 0x4F + class #68; // #17 at 0x54 + Utf8 "x"; // #18 at 0x57 + Utf8 "I"; // #19 at 0x5B + Utf8 "y"; // #20 at 0x5F + Utf8 "<init>"; // #21 at 0x63 + Utf8 "()V"; // #22 at 0x6C + Utf8 "Code"; // #23 at 0x72 + Utf8 "LineNumberTable"; // #24 at 0x79 + Utf8 "getX"; // #25 at 0x8B + Utf8 "()I"; // #26 at 0x92 + Utf8 "getY"; // #27 at 0x98 + Utf8 "toString"; // #28 at 0x9F + Utf8 "()Ljava/lang/String;"; // #29 at 0xAA + Utf8 "objArray"; // #30 at 0xC1 + Utf8 "([Ljava/lang/Object;)V"; // #31 at 0xCC + Utf8 "createNoArrayCov"; // #32 at 0xE5 + Utf8 "NoArrayCov"; // #33 at 0xF8 + Utf8 "ValueTypes"; // #34 at 0x0105 + Utf8 "(II)QNoArrayCov;"; // #35 at 0x0112 + Utf8 "main"; // #36 at 0x0125 + Utf8 "([Ljava/lang/String;)V"; // #37 at 0x012C + Utf8 "hashCode"; // #38 at 0x0145 + Utf8 "equals"; // #39 at 0x0150 + Utf8 "(Ljava/lang/Object;)Z"; // #40 at 0x0159 + Utf8 "longHashCode"; // #41 at 0x0171 + Utf8 "()J"; // #42 at 0x0180 + Utf8 "$makeValue$"; // #43 at 0x0186 + Utf8 "()QNoArrayCov;"; // #44 at 0x0194 + Utf8 "SourceFile"; // #45 at 0x01A5 + Utf8 "NoArrayCov.java"; // #46 at 0x01B2 + NameAndType #21 #22; // #47 at 0x01C4 + NameAndType #18 #19; // #48 at 0x01C9 + NameAndType #20 #19; // #49 at 0x01CE + NameAndType #25 #26; // #50 at 0x01D3 + NameAndType #27 #26; // #51 at 0x01D8 + Utf8 "BootstrapMethods"; // #52 at 0x01DD + MethodHandle 6b #69; // #53 at 0x01F0 + String #70; // #54 at 0x01F4 + NameAndType #71 #72; // #55 at 0x01F7 + class #73; // #56 at 0x01FC + NameAndType #74 #75; // #57 at 0x01FF + Utf8 "In objArray"; // #58 at 0x0204 + class #76; // #59 at 0x0212 + NameAndType #77 #78; // #60 at 0x0215 + NameAndType #32 #35; // #61 at 0x021A + Utf8 "QNoArrayCov;"; // #62 at 0x021F + NameAndType #30 #31; // #63 at 0x022E + MethodHandle 6b #79; // #64 at 0x0233 + NameAndType #38 #80; // #65 at 0x0237 + NameAndType #39 #81; // #66 at 0x023C + NameAndType #41 #82; // #67 at 0x0241 + Utf8 "java/lang/Object"; // #68 at 0x0246 + Method #83 #84; // #69 at 0x0259 + Utf8 "NoArrayCov: x= y="; // #70 at 0x025E + Utf8 "makeConcatWithConstants"; // #71 at 0x0274 + Utf8 "(II)Ljava/lang/String;"; // #72 at 0x028E + Utf8 "java/lang/System"; // #73 at 0x02A7 + Utf8 "out"; // #74 at 0x02BA + Utf8 "Ljava/io/PrintStream;"; // #75 at 0x02C0 + Utf8 "java/io/PrintStream"; // #76 at 0x02D8 + Utf8 "println"; // #77 at 0x02EE + Utf8 "(Ljava/lang/String;)V"; // #78 at 0x02F8 + Method #85 #86; // #79 at 0x0310 + Utf8 "(Ljava/lang/Object;)I"; // #80 at 0x0315 + Utf8 "(Ljava/lang/Object;Ljava/lang/Object;)Z"; // #81 at 0x032D + Utf8 "(Ljava/lang/Object;)J"; // #82 at 0x0357 + class #87; // #83 at 0x036F + NameAndType #71 #91; // #84 at 0x0372 + class #92; // #85 at 0x0377 + NameAndType #93 #94; // #86 at 0x037A + Utf8 "java/lang/invoke/StringConcatFactory"; // #87 at 0x037F + class #96; // #88 at 0x03A6 + Utf8 "Lookup"; // #89 at 0x03A9 + Utf8 "InnerClasses"; // #90 at 0x03B2 + 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 + Utf8 "java/lang/invoke/ValueBootstrapMethods"; // #92 at 0x045C + Utf8 "makeBootstrapMethod"; // #93 at 0x0485 + Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; // #94 at 0x049B + class #97; // #95 at 0x0511 + Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #96 at 0x0514 + Utf8 "java/lang/invoke/MethodHandles"; // #97 at 0x053C + } // Constant Pool + + 0x0131; // access [ ACC_PUBLIC ACC_SUPER ACC_FINAL ] + #10;// this_cpx + #17;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [2] { // fields + { // Member at 0x0567 + 0x0010; // access + #18; // name_cpx + #19; // sig_cpx + [0] { // Attributes + } // Attributes + } // Member + ; + { // Member at 0x056F + 0x0010; // access + #20; // name_cpx + #19; // sig_cpx + [0] { // Attributes + } // Attributes + } // Member + } // fields + + [11] { // methods + { // Member at 0x0579 + 0x0002; // access + #21; // name_cpx + #22; // sig_cpx + [1] { // Attributes + Attr(#23, 29) { // Code at 0x0581 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 6) { // LineNumberTable at 0x0598 + [1] { // LineNumberTable + 0 28; // at 0x05A4 + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x05A4 + 0x0001; // access + #25; // name_cpx + #26; // sig_cpx + [1] { // Attributes + Attr(#23, 29) { // Code at 0x05AC + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB40002AC; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 6) { // LineNumberTable at 0x05C3 + [1] { // LineNumberTable + 0 33; // at 0x05CF + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x05CF + 0x0001; // access + #27; // name_cpx + #26; // sig_cpx + [1] { // Attributes + Attr(#23, 29) { // Code at 0x05D7 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB40003AC; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 6) { // LineNumberTable at 0x05EE + [1] { // LineNumberTable + 0 34; // at 0x05FA + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x05FA + 0x0001; // access + #28; // name_cpx + #29; // sig_cpx + [1] { // Attributes + Attr(#23, 38) { // Code at 0x0602 + 2; // max_stack + 1; // max_locals + Bytes[14]{ + 0x2AB600042AB60005; + 0xBA00060000B0; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 6) { // LineNumberTable at 0x0622 + [1] { // LineNumberTable + 0 37; // at 0x062E + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x062E + 0x0001; // access + #30; // name_cpx + #31; // sig_cpx + [1] { // Attributes + Attr(#23, 37) { // Code at 0x0636 + 2; // max_stack + 2; // max_locals + Bytes[9]{ + 0xB200071208B60009; + 0xB1; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 10) { // LineNumberTable at 0x0651 + [2] { // LineNumberTable + 0 41; // at 0x065D + 8 42; // at 0x0661 + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0661 + 0x0009; // access + #32; // name_cpx + #35; // sig_cpx + [1] { // Attributes + Attr(#23, 56) { // Code at 0x0669 + 2; // max_stack + 3; // max_locals + Bytes[20]{ + 0xCB000A4D1A2C5FCC; + 0x00024D1B2C5FCC00; + 0x034D2CB0; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 18) { // LineNumberTable at 0x068F + [4] { // LineNumberTable + 0 45; // at 0x069B + 4 46; // at 0x069F + 11 47; // at 0x06A3 + 18 48; // at 0x06A7 + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x06A7 + 0x0009; // access + #36; // name_cpx + #37; // sig_cpx + [1] { // Attributes + Attr(#23, 79) { // Code at 0x06AF + 3; // max_stack + 4; // max_locals + Bytes[31]{ + 0x0607B8000B4C0507; + 0xB8000B4D05BD000C; + 0x4E2D032B532D042C; + 0x532B2DB6000DB1; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 30) { // LineNumberTable at 0x06E0 + [7] { // LineNumberTable + 0 52; // at 0x06EC + 6 53; // at 0x06F0 + 12 54; // at 0x06F4 + 17 55; // at 0x06F8 + 21 56; // at 0x06FC + 25 57; // at 0x0700 + 30 58; // at 0x0704 + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0704 + 0x0011; // access + #38; // name_cpx + #26; // sig_cpx + [1] { // Attributes + Attr(#23, 31) { // Code at 0x070C + 1; // max_stack + 1; // max_locals + Bytes[7]{ + 0x2ABA000E0000AC; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 6) { // LineNumberTable at 0x0725 + [1] { // LineNumberTable + 0 24; // at 0x0731 + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0731 + 0x0011; // access + #39; // name_cpx + #40; // sig_cpx + [1] { // Attributes + Attr(#23, 32) { // Code at 0x0739 + 2; // max_stack + 2; // max_locals + Bytes[8]{ + 0x2A2BBA000F0000AC; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 6) { // LineNumberTable at 0x0753 + [1] { // LineNumberTable + 0 24; // at 0x075F + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x075F + 0x0011; // access + #41; // name_cpx + #42; // sig_cpx + [1] { // Attributes + Attr(#23, 31) { // Code at 0x0767 + 2; // max_stack + 1; // max_locals + Bytes[7]{ + 0x2ABA00100000AD; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 6) { // LineNumberTable at 0x0780 + [1] { // LineNumberTable + 0 24; // at 0x078C + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x078C + 0x100A; // access + #43; // name_cpx + #44; // sig_cpx + [1] { // Attributes + Attr(#23, 56) { // Code at 0x0794 + 2; // max_stack + 1; // max_locals + Bytes[20]{ + 0xCB000A4B032A5FCC; + 0x00024B032A5FCC00; + 0x034B2AB0; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#24, 18) { // LineNumberTable at 0x07BA + [4] { // LineNumberTable + 0 28; // at 0x07C6 + 4 29; // at 0x07CA + 11 30; // at 0x07CE + 18 31; // at 0x07D2 + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [4] { // Attributes + Attr(#45, 2) { // SourceFile at 0x07D4 + #46; + } // end SourceFile + ; + Attr(#90, 10) { // InnerClasses at 0x07DC + [1] { // InnerClasses + #88 #95 #89 25; // at 0x07EC + } + } // end InnerClasses + ; + Attr(#52, 12) { // BootstrapMethods at 0x07EC + [2] { // bootstrap_methods + { // bootstrap_method + #53; // bootstrap_method_ref + [1] { // bootstrap_arguments + #54; // at 0x07FA + } // bootstrap_arguments + } // bootstrap_method + ; + { // bootstrap_method + #64; // bootstrap_method_ref + [0] { // bootstrap_arguments + } // bootstrap_arguments + } // bootstrap_method + } + } // end BootstrapMethods + ; + Attr(#34, 4) { // ValueTypes at 0x07FE + 0x0001000A; + } // end ValueTypes + } // Attributes +} // end class NoArrayCov
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/NoArrayCovIntf.jcod Fri Dec 14 13:15:10 2018 -0500 @@ -0,0 +1,499 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +// Test that a VerifyError exception is thrown when trying to pass a value +// type array when the formal parameter is an array of an interface type. +// +// // Java program emulating the jcod contents. +// interface II { } +// +// public value final class NoArrayCovIntf { +// final int x; +// final int y; +// +// private NoArrayCovIntf() { +// x = 0; +// y = 0; +// } +// +// public int getX() { return x; } +// public int getY() { return y; } +// +// public String toString() { +// return "NoArrayCovIntf: x=" + getX() + " y=" + getY(); +// } +// +// public void iiArray(ii[] oArr) { +// System.out.println("In iiArray"); +// } +// +// public static NoArrayCovIntf createNoArrayCovIntf(int x, int y) { +// NoArrayCovIntf p = NoArrayCovIntf.default; +// p = __WithField(p.x, x); +// p = __WithField(p.y, y); +// return p; +// } +// +// public static void main(String[] args) { +// NoArrayCovIntf a = createNoArrayCovIntf(3, 4); +// NoArrayCovIntf b = createNoArrayCovIntf(2, 4); +// NoArrayCovIntf pa[] = new NoArrayCovIntf[2]; +// pa[0] = a; +// pa[1] = b; +// a.iiArray(pa); // Should throw VerifyError. +// } +// } + + +class II { + 0xCAFEBABE; + 0; // minor version + 56; // version + [7] { // Constant Pool + ; // first element is empty + class #5; // #1 at 0x0A + class #6; // #2 at 0x0D + Utf8 "SourceFile"; // #3 at 0x10 + Utf8 "II.java"; // #4 at 0x1D + Utf8 "II"; // #5 at 0x33 + Utf8 "java/lang/Object"; // #6 at 0x37 + } // Constant Pool + + 0x0600; // access [ ACC_INTERFACE ] + #1;// this_cpx + #2;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [0] { // fields + } // fields + + [0] { // methods + } // methods + + [1] { // Attributes + Attr(#3, 2) { // SourceFile at 0x58 + #4; + } // end SourceFile + } // Attributes +} // end class II + + +class NoArrayCovIntf { + 0xCAFEBABE; + 0; // minor version + 56; // version + [99] { // Constant Pool + ; // first element is empty + String #58; // #1 at 0x0A + Method #66 #19; // #2 at 0x0D + InvokeDynamic 3s #63; // #3 at 0x12 + class #38; // #4 at 0x17 + class #39; // #5 at 0x1A + Method #24 #50; // #6 at 0x1D + Method #4 #85; // #7 at 0x22 + InvokeDynamic 1s #36; // #8 at 0x27 + Method #4 #73; // #9 at 0x2C + Field #65 #89; // #10 at 0x31 + InvokeDynamic 2s #30; // #11 at 0x36 + Method #4 #57; // #12 at 0x3B + Field #4 #34; // #13 at 0x40 + Field #4 #56; // #14 at 0x45 + InvokeDynamic 0s #93; // #15 at 0x4A + Method #4 #32; // #16 at 0x4F + Utf8 "java/io/PrintStream"; // #17 at 0x54 + Utf8 "NoArrayCovIntf.jasm"; // #18 at 0x6A + NameAndType #88 #62; // #19 at 0x80 + Utf8 "([LII;)V"; // #20 at 0x85 + Utf8 "java/lang/invoke/ValueBootstrapMethods"; // #21 at 0x8F + Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #22 at 0xB8 + MethodHandle 6b #43; // #23 at 0xE0 + class #17; // #24 at 0xE4 + Utf8 "SourceFile"; // #25 at 0xE7 + Utf8 "iiArray"; // #26 at 0xF4 + class #21; // #27 at 0xFF + Utf8 "Lookup"; // #28 at 0x0102 + class #22; // #29 at 0x010B + NameAndType #60 #40; // #30 at 0x010E + Utf8 "hashCode"; // #31 at 0x0113 + NameAndType #77 #75; // #32 at 0x011E + Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;"; // #33 at 0x0123 + NameAndType #95 #35; // #34 at 0x01BE + Utf8 "I"; // #35 at 0x01C3 + NameAndType #31 #68; // #36 at 0x01C7 + Utf8 "Code"; // #37 at 0x01CC + Utf8 "NoArrayCovIntf"; // #38 at 0x01D3 + Utf8 "QNoArrayCovIntf;"; // #39 at 0x01E4 + Utf8 "(Ljava/lang/Object;Ljava/lang/Object;)Z"; // #40 at 0x01F7 + NameAndType #91 #33; // #41 at 0x0221 + Utf8 "createNoArrayCovIntf"; // #42 at 0x0226 + Method #96 #41; // #43 at 0x023D + Utf8 "([Ljava/lang/String;)V"; // #44 at 0x0242 + Utf8 "out"; // #45 at 0x025B + Utf8 "$makeValue$"; // #46 at 0x0261 + Utf8 "BootstrapMethods"; // #47 at 0x026F + String #67; // #48 at 0x0282 + Utf8 "toString"; // #49 at 0x0285 + NameAndType #53 #69; // #50 at 0x0290 + Utf8 "java/lang/invoke/MethodHandles"; // #51 at 0x0295 + Utf8 "(Ljava/lang/Object;)Z"; // #52 at 0x02B6 + Utf8 "println"; // #53 at 0x02CE + Utf8 "java/lang/Object"; // #54 at 0x02D8 + Utf8 "java/lang/System"; // #55 at 0x02EB + NameAndType #92 #35; // #56 at 0x02FE + NameAndType #26 #20; // #57 at 0x0303 + Utf8 "In iiArray"; // #58 at 0x0308 + class #51; // #59 at 0x0316 + Utf8 "equals"; // #60 at 0x0319 + NameAndType #72 #79; // #61 at 0x0322 + Utf8 "()V"; // #62 at 0x0327 + NameAndType #97 #64; // #63 at 0x032D + Utf8 "(Ljava/lang/Object;)J"; // #64 at 0x0332 + class #55; // #65 at 0x034A + class #54; // #66 at 0x034D + Utf8 "NoArrayCovIntf: x= y="; // #67 at 0x0350 + Utf8 "(Ljava/lang/Object;)I"; // #68 at 0x036A + Utf8 "(Ljava/lang/String;)V"; // #69 at 0x0382 + Utf8 "main"; // #70 at 0x039A + Method #27 #61; // #71 at 0x03A1 + Utf8 "makeBootstrapMethod"; // #72 at 0x03A6 + NameAndType #42 #78; // #73 at 0x03BC + Utf8 "()J"; // #74 at 0x03C1 + Utf8 "()I"; // #75 at 0x03C7 + Utf8 "getY"; // #76 at 0x03CD + Utf8 "getX"; // #77 at 0x03D4 + Utf8 "(II)QNoArrayCovIntf;"; // #78 at 0x03DB + Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; // #79 at 0x03F2 + Utf8 "InnerClasses"; // #80 at 0x0468 + Utf8 "()QNoArrayCovIntf;"; // #81 at 0x0477 + MethodHandle 6b #71; // #82 at 0x048C + MethodHandle 6b #71; // #83 at 0x0490 + MethodHandle 6b #71; // #84 at 0x0494 + NameAndType #76 #75; // #85 at 0x0498 + Utf8 "Ljava/io/PrintStream;"; // #86 at 0x049D + Utf8 "java/lang/invoke/StringConcatFactory"; // #87 at 0x04B5 + Utf8 "<init>"; // #88 at 0x04DC + NameAndType #45 #86; // #89 at 0x04E5 + Utf8 "()Ljava/lang/String;"; // #90 at 0x04EA + Utf8 "makeConcatWithConstants"; // #91 at 0x0501 + Utf8 "y"; // #92 at 0x051B + NameAndType #91 #98; // #93 at 0x051F + Utf8 "ValueTypes"; // #94 at 0x0524 + Utf8 "x"; // #95 at 0x0531 + class #87; // #96 at 0x0535 + Utf8 "longHashCode"; // #97 at 0x0538 + Utf8 "(I)Ljava/lang/String;"; // #98 at 0x0547 + } // Constant Pool + + 0x0131; // access [ ACC_PUBLIC ACC_SUPER ACC_FINAL ] + #4;// this_cpx + #66;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [2] { // fields + { // Member at 0x056A + 0x0010; // access + #95; // name_cpx + #35; // sig_cpx + [0] { // Attributes + } // Attributes + } // Member + ; + { // Member at 0x0572 + 0x0010; // access + #92; // name_cpx + #35; // sig_cpx + [0] { // Attributes + } // Attributes + } // Member + } // fields + + [11] { // methods + { // Member at 0x057C + 0x0002; // access + #88; // name_cpx + #62; // sig_cpx + [1] { // Attributes + Attr(#37, 17) { // Code at 0x0584 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70002B1; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x059B + 0x0001; // access + #77; // name_cpx + #75; // sig_cpx + [1] { // Attributes + Attr(#37, 17) { // Code at 0x05A3 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB4000DAC; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x05BA + 0x0001; // access + #76; // name_cpx + #75; // sig_cpx + [1] { // Attributes + Attr(#37, 17) { // Code at 0x05C2 + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB4000EAC; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x05D9 + 0x0001; // access + #49; // name_cpx + #90; // sig_cpx + [1] { // Attributes + Attr(#37, 26) { // Code at 0x05E1 + 2; // max_stack + 1; // max_locals + Bytes[14]{ + 0x2AB600102AB60007; + 0xBA000F0000B0; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0601 + 0x0001; // access + #26; // name_cpx + #20; // sig_cpx + [1] { // Attributes + Attr(#37, 21) { // Code at 0x0609 + 2; // max_stack + 2; // max_locals + Bytes[9]{ + 0xB2000A1201B60006; + 0xB1; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0624 + 0x0009; // access + #42; // name_cpx + #78; // sig_cpx + [1] { // Attributes + Attr(#37, 32) { // Code at 0x062C + 2; // max_stack + 3; // max_locals + Bytes[20]{ + 0xCB00044D1A2C5FCC; + 0x000D4D1B2C5FCC00; + 0x0E4D2CB0; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0652 + 0x0009; // access + #70; // name_cpx + #44; // sig_cpx + [1] { // Attributes + Attr(#37, 43) { // Code at 0x065A + 3; // max_stack + 4; // max_locals + Bytes[31]{ + 0x0607B800094C0507; + 0xB800094D05BD0005; + 0x4E2D032B532D042C; + 0x532B2DB6000CB1; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x068B + 0x0011; // access + #31; // name_cpx + #75; // sig_cpx + [1] { // Attributes + Attr(#37, 19) { // Code at 0x0693 + 1; // max_stack + 1; // max_locals + Bytes[7]{ + 0x2ABA00080000AC; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x06AC + 0x0011; // access + #60; // name_cpx + #52; // sig_cpx + [1] { // Attributes + Attr(#37, 20) { // Code at 0x06B4 + 2; // max_stack + 2; // max_locals + Bytes[8]{ + 0x2A2BBA000B0000AC; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x06CE + 0x0011; // access + #97; // name_cpx + #74; // sig_cpx + [1] { // Attributes + Attr(#37, 19) { // Code at 0x06D6 + 2; // max_stack + 1; // max_locals + Bytes[7]{ + 0x2ABA00030000AD; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x06EF + 0x100A; // access + #46; // name_cpx + #81; // sig_cpx + [1] { // Attributes + Attr(#37, 32) { // Code at 0x06F7 + 2; // max_stack + 1; // max_locals + Bytes[20]{ + 0xCB00044B032A5FCC; + 0x000D4B032A5FCC00; + 0x0E4B2AB0; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [4] { // Attributes + Attr(#25, 2) { // SourceFile at 0x071F + #18; + } // end SourceFile + ; + Attr(#80, 10) { // InnerClasses at 0x0727 + [1] { // InnerClasses + #29 #59 #28 25; // at 0x0737 + } + } // end InnerClasses + ; + Attr(#47, 20) { // BootstrapMethods at 0x0737 + [4] { // bootstrap_methods + { // bootstrap_method + #23; // bootstrap_method_ref + [1] { // bootstrap_arguments + #48; // at 0x0745 + } // bootstrap_arguments + } // bootstrap_method + ; + { // bootstrap_method + #84; // bootstrap_method_ref + [0] { // bootstrap_arguments + } // bootstrap_arguments + } // bootstrap_method + ; + { // bootstrap_method + #83; // bootstrap_method_ref + [0] { // bootstrap_arguments + } // bootstrap_arguments + } // bootstrap_method + ; + { // bootstrap_method + #82; // bootstrap_method_ref + [0] { // bootstrap_arguments + } // bootstrap_arguments + } // bootstrap_method + } + } // end BootstrapMethods + ; + Attr(#94, 4) { // ValueTypes at 0x0751 + 0x00010004; + } // end ValueTypes + } // Attributes +} // end class NoArrayCovIntf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/NoNullVT.jcod Fri Dec 14 13:15:10 2018 -0500 @@ -0,0 +1,465 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +// Test that a VerifyError exception is thrown when trying to pass a null +// when the formal parameter is a value type. +// +// // Java program emulating the jcod contents. +// public value final class NoNullVT { +// final int x; +// final int y; +// +// private NoNullVT() { +// x = 0; +// y = 0; +// } +// +// public int getX() { return x; } +// public int getY() { return y; } +// +// public boolean isSameNoNullVT(NoNullVT that) { +// return this.getX() == that.getX() && this.getY() == that.getY(); +// } +// +// public boolean equals(Object o) { +// if(o instanceof NoNullVT) { +// return ((NoNullVT)o).x == x && ((NoNullVT)o).y == y; +// } else { +// return false; +// } +// } +// +// public static NoNullVT createNoNullVT(int x, int y) { +// NoNullVT p = NoNullVT.default; +// p = __WithField(p.x, x); +// p = __WithField(p.y, y); +// return p; +// } +// +// public static void main(String[] args) { +// String str = null; +// NoNullVT a = createNoNullVT(3, 4); +// NoNullVT b = createNoNullVT(2, 4); +// boolean res = a.isSameNoNullVT(null); // Should throw VerifyError +// } +// } + + +class NoNullVT { + 0xCAFEBABE; + 0; // minor version + 56; // version + [86] { // Constant Pool + ; // first element is empty + Method #54 #13; // #1 at 0x0A + Field #10 #47; // #2 at 0x0F + InvokeDynamic 2s #52; // #3 at 0x14 + InvokeDynamic 1s #29; // #4 at 0x19 + Method #10 #24; // #5 at 0x1E + Method #10 #72; // #6 at 0x23 + Field #10 #26; // #7 at 0x28 + Method #63 #40; // #8 at 0x2D + InvokeDynamic 0s #80; // #9 at 0x32 + class #68; // #10 at 0x37 + Method #10 #27; // #11 at 0x3A + Method #10 #73; // #12 at 0x3F + NameAndType #75 #51; // #13 at 0x44 + Utf8 "java/lang/invoke/ValueBootstrapMethods"; // #14 at 0x49 + Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #15 at 0x72 + Utf8 "createNoNullVT"; // #16 at 0x9A + MethodHandle 6b #36; // #17 at 0xAC + Utf8 "SourceFile"; // #18 at 0xB0 + class #14; // #19 at 0xBD + Utf8 "Lookup"; // #20 at 0xC0 + class #15; // #21 at 0xC9 + Utf8 "hashCode"; // #22 at 0xCC + Utf8 "(Ljava/lang/Object;)Ljava/lang/Object;"; // #23 at 0xD7 + NameAndType #65 #62; // #24 at 0x0100 + 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 + NameAndType #82 #28; // #26 at 0x01A0 + NameAndType #16 #61; // #27 at 0x01A5 + Utf8 "I"; // #28 at 0x01AA + NameAndType #22 #55; // #29 at 0x01AE + Utf8 "Code"; // #30 at 0x01B3 + Utf8 "requireNonNull"; // #31 at 0x01BA + String #45; // #32 at 0x01CB + Utf8 "StackMapTable"; // #33 at 0x01CE + NameAndType #77 #25; // #34 at 0x01DE + Utf8 "NoNullVT.jasm"; // #35 at 0x01E3 + Method #83 #34; // #36 at 0x01F4 + Utf8 "([Ljava/lang/String;)V"; // #37 at 0x01F9 + Utf8 "$makeValue$"; // #38 at 0x0212 + Utf8 "BootstrapMethods"; // #39 at 0x0220 + NameAndType #31 #23; // #40 at 0x0233 + Utf8 "toString"; // #41 at 0x0238 + Utf8 "isSameNoNullVT"; // #42 at 0x0243 + Utf8 "java/lang/invoke/MethodHandles"; // #43 at 0x0255 + Utf8 "(Ljava/lang/Object;)Z"; // #44 at 0x0276 + Utf8 "NoNullVT: x= y="; // #45 at 0x028E + Utf8 "java/lang/Object"; // #46 at 0x02A3 + NameAndType #79 #28; // #47 at 0x02B6 + class #43; // #48 at 0x02BB + NameAndType #59 #66; // #49 at 0x02BE + Utf8 "equals"; // #50 at 0x02C3 + Utf8 "()V"; // #51 at 0x02CC + NameAndType #84 #53; // #52 at 0x02D2 + Utf8 "(Ljava/lang/Object;)J"; // #53 at 0x02D7 + class #46; // #54 at 0x02EF + Utf8 "(Ljava/lang/Object;)I"; // #55 at 0x02F2 + Utf8 "java/util/Objects"; // #56 at 0x030A + Utf8 "main"; // #57 at 0x031E + Method #19 #49; // #58 at 0x0325 + Utf8 "makeBootstrapMethod"; // #59 at 0x032A + Utf8 "()J"; // #60 at 0x0340 + Utf8 "(II)QNoNullVT;"; // #61 at 0x0346 + Utf8 "()I"; // #62 at 0x0358 + class #56; // #63 at 0x035E + Utf8 "getY"; // #64 at 0x0361 + Utf8 "getX"; // #65 at 0x0368 + Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;"; // #66 at 0x036F + Utf8 "InnerClasses"; // #67 at 0x03E5 + Utf8 "NoNullVT"; // #68 at 0x03F4 + Utf8 "(QNoNullVT;)Z"; // #69 at 0x0400 + MethodHandle 6b #58; // #70 at 0x0411 + MethodHandle 6b #58; // #71 at 0x0415 + NameAndType #64 #62; // #72 at 0x0419 + NameAndType #42 #69; // #73 at 0x041E + Utf8 "java/lang/invoke/StringConcatFactory"; // #74 at 0x0423 + Utf8 "<init>"; // #75 at 0x044A + Utf8 "()Ljava/lang/String;"; // #76 at 0x0453 + Utf8 "makeConcatWithConstants"; // #77 at 0x046A + Utf8 "()QNoNullVT;"; // #78 at 0x0484 + Utf8 "y"; // #79 at 0x0494 + NameAndType #77 #85; // #80 at 0x0498 + Utf8 "ValueTypes"; // #81 at 0x049D + Utf8 "x"; // #82 at 0x04AA + class #74; // #83 at 0x04AE + Utf8 "longHashCode"; // #84 at 0x04B1 + Utf8 "(II)Ljava/lang/String;"; // #85 at 0x04C0 + } // Constant Pool + + 0x0131; // access [ ACC_PUBLIC ACC_SUPER ACC_FINAL ] + #10;// this_cpx + #54;// super_cpx + + [0] { // Interfaces + } // Interfaces + + [2] { // fields + { // Member at 0x04E3 + 0x0010; // access + #82; // name_cpx + #28; // sig_cpx + [0] { // Attributes + } // Attributes + } // Member + ; + { // Member at 0x04EB + 0x0010; // access + #79; // name_cpx + #28; // sig_cpx + [0] { // Attributes + } // Attributes + } // Member + } // fields + + [11] { // methods + { // Member at 0x04F5 + 0x0002; // access + #75; // name_cpx + #51; // sig_cpx + [1] { // Attributes + Attr(#30, 17) { // Code at 0x04FD + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB70001B1; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0514 + 0x0001; // access + #65; // name_cpx + #62; // sig_cpx + [1] { // Attributes + Attr(#30, 17) { // Code at 0x051C + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB40007AC; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0533 + 0x0001; // access + #64; // name_cpx + #62; // sig_cpx + [1] { // Attributes + Attr(#30, 17) { // Code at 0x053B + 1; // max_stack + 1; // max_locals + Bytes[5]{ + 0x2AB40002AC; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0552 + 0x0001; // access + #42; // name_cpx + #69; // sig_cpx + [1] { // Attributes + Attr(#30, 51) { // Code at 0x055A + 2; // max_stack + 2; // max_locals + Bytes[28]{ + 0x2AB600052BB60005; + 0xA000122AB600062B; + 0xB60006A0000704A7; + 0x000403AC; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#33, 5) { // StackMapTable at 0x0588 + [2] { // + 26b; // same_frame + 64b, [1]z{1b}; // same_locals_1_stack_item_frame + } + } // end StackMapTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0593 + 0x0001; // access + #41; // name_cpx + #76; // sig_cpx + [1] { // Attributes + Attr(#30, 26) { // Code at 0x059B + 2; // max_stack + 1; // max_locals + Bytes[14]{ + 0x2AB600052AB60006; + 0xBA00090000B0; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x05BB + 0x0001; // access + #50; // name_cpx + #44; // sig_cpx + [1] { // Attributes + Attr(#30, 77) { // Code at 0x05C3 + 2; // max_stack + 2; // max_locals + Bytes[53]{ + 0x2BC1000A99002F2B; + 0x59B8000857C0000A; + 0xB400072AB40007A0; + 0x001A2B59B8000857; + 0xC0000AB400022AB4; + 0x0002A0000704A700; + 0x0403AC03AC; + }; + [0] { // Traps + } // end Traps + [1] { // Attributes + Attr(#33, 6) { // StackMapTable at 0x060A + [3] { // + 49b; // same_frame + 64b, [1]z{1b}; // same_locals_1_stack_item_frame + 0b; // same_frame + } + } // end StackMapTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0616 + 0x0009; // access + #16; // name_cpx + #61; // sig_cpx + [1] { // Attributes + Attr(#30, 32) { // Code at 0x061E + 2; // max_stack + 3; // max_locals + Bytes[20]{ + 0xCB000A4D1A2C5FCC; + 0x00074D1B2C5FCC00; + 0x024D2CB0; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0644 + 0x0009; // access + #57; // name_cpx + #37; // sig_cpx + [1] { // Attributes + Attr(#30, 34) { // Code at 0x064C + 2; // max_stack + 5; // max_locals + Bytes[22]{ + 0x014C0607B8000B4D; + 0x0507B8000B4E2C2B; + 0xB6000C3604B1; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0674 + 0x0011; // access + #22; // name_cpx + #62; // sig_cpx + [1] { // Attributes + Attr(#30, 19) { // Code at 0x067C + 1; // max_stack + 1; // max_locals + Bytes[7]{ + 0x2ABA00040000AC; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x0695 + 0x0011; // access + #84; // name_cpx + #60; // sig_cpx + [1] { // Attributes + Attr(#30, 19) { // Code at 0x069D + 2; // max_stack + 1; // max_locals + Bytes[7]{ + 0x2ABA00030000AD; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member at 0x06B6 + 0x100A; // access + #38; // name_cpx + #78; // sig_cpx + [1] { // Attributes + Attr(#30, 32) { // Code at 0x06BE + 2; // max_stack + 1; // max_locals + Bytes[20]{ + 0xCB000A4B032A5FCC; + 0x00074B032A5FCC00; + 0x024B2AB0; + }; + [0] { // Traps + } // end Traps + [0] { // Attributes + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [4] { // Attributes + Attr(#18, 2) { // SourceFile at 0x06E6 + #35; + } // end SourceFile + ; + Attr(#67, 10) { // InnerClasses at 0x06EE + [1] { // InnerClasses + #21 #48 #20 25; // at 0x06FE + } + } // end InnerClasses + ; + Attr(#39, 16) { // BootstrapMethods at 0x06FE + [3] { // bootstrap_methods + { // bootstrap_method + #17; // bootstrap_method_ref + [1] { // bootstrap_arguments + #32; // at 0x070C + } // bootstrap_arguments + } // bootstrap_method + ; + { // bootstrap_method + #71; // bootstrap_method_ref + [0] { // bootstrap_arguments + } // bootstrap_arguments + } // bootstrap_method + ; + { // bootstrap_method + #70; // bootstrap_method_ref + [0] { // bootstrap_arguments + } // bootstrap_arguments + } // bootstrap_method + } + } // end BootstrapMethods + ; + Attr(#81, 4) { // ValueTypes at 0x0714 + 0x0001000A; + } // end ValueTypes + } // Attributes +} // end class NoNullVT
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/VTAssignability.java Fri Dec 14 13:15:10 2018 -0500 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Test basic verifier assignability of value types. + * @compile -XDallowWithFieldOperator -XDemitQtypes VTAssignability.java + * @run main/othervm -Xverify:remote -XX:+EnableValhalla VTAssignability + */ + +// Test that a value type is assignable to itself, to java.lang.Object, +// and to an interface, +// +interface II { } + +public value final class VTAssignability implements II { + final int x; + final int y; + + private VTAssignability() { + x = 0; + y = 0; + } + + public int getX() { return x; } + public int getY() { return y; } + + public boolean isSameVTAssignability(VTAssignability that) { + return this.getX() == that.getX() && this.getY() == that.getY(); + } + + public boolean equals(Object o) { + if(o instanceof VTAssignability) { + return ((VTAssignability)o).x == x && ((VTAssignability)o).y == y; + } else { + return false; + } + } + + public void takesInterface(II i) { + System.out.println("Test passes!!"); + } + + public static VTAssignability createVTAssignability(int x, int y) { + VTAssignability p = VTAssignability.default; + p = __WithField(p.x, x); + p = __WithField(p.y, y); + return p; + } + + public static void main(String[] args) { + VTAssignability a = createVTAssignability(3, 4); + VTAssignability b = createVTAssignability(2, 4); + + // Test assignability of a value type to itself. + boolean res = a.isSameVTAssignability(b); + + // Test assignability of a value type to java.lang.Object. + res = b.equals(a); + + // Test assignability of a value type to an interface. + a.takesInterface(b); + } +}
--- a/test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/VerifierValueTypes.java Thu Dec 13 22:58:36 2018 -0800 +++ b/test/hotspot/jtreg/runtime/valhalla/valuetypes/verifier/VerifierValueTypes.java Fri Dec 14 13:15:10 2018 -0500 @@ -25,7 +25,7 @@ * @test * @summary test that the right exceptions get thrown for bad value type * class files. - * @compile verifierTests.jcod + * @compile verifierTests.jcod NoArrayCov.jcod NoArrayCovIntf.jcod NoNullVT.jcod * @run main/othervm -verify -XX:+EnableValhalla VerifierValueTypes */ @@ -95,5 +95,17 @@ // Test VerifyError is thrown if a withfield's class operand is not a value type. runTestVerifyError("withfieldObj", "Bad type on operand stack"); + + // Test that an array of value types is not assignable to [Ljava/lang/Object;. + runTestVerifyError("NoArrayCov", + "Type '[QNoArrayCov;' (current frame, stack[1]) is not assignable to '[Ljava/lang/Object;'"); + + // Test that an array of value types is not assignable to an array of interfaces. + runTestVerifyError("NoArrayCovIntf", + "Type '[QNoArrayCovIntf;' (current frame, stack[1]) is not assignable to '[LII;'"); + + // Test that null is not assignable to a value type. + runTestVerifyError("NoNullVT", + "Type null (current frame, stack[1]) is not assignable to 'QNoNullVT;'"); } }