1 /* 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 // Test that a VerifyError exception is thrown when trying to pass a value 26 // type array when the formal parameter is an array of an interface type. 27 // 28 // // Java program emulating the jcod contents. 29 // interface II { } 30 // 31 // public value final class NoArrayCovIntf { 32 // final int x; 33 // final int y; 34 // 35 // private NoArrayCovIntf() { 36 // x = 0; 37 // y = 0; 38 // } 39 // 40 // public int getX() { return x; } 41 // public int getY() { return y; } 42 // 43 // public String toString() { 44 // return "NoArrayCovIntf: x=" + getX() + " y=" + getY(); 45 // } 46 // 47 // public void iiArray(ii[] oArr) { 48 // System.out.println("In iiArray"); 49 // } 50 // 51 // public static NoArrayCovIntf createNoArrayCovIntf(int x, int y) { 52 // NoArrayCovIntf p = NoArrayCovIntf.default; 53 // p = __WithField(p.x, x); 54 // p = __WithField(p.y, y); 55 // return p; 56 // } 57 // 58 // public static void main(String[] args) { 59 // NoArrayCovIntf a = createNoArrayCovIntf(3, 4); 60 // NoArrayCovIntf b = createNoArrayCovIntf(2, 4); 61 // NoArrayCovIntf pa[] = new NoArrayCovIntf[2]; 62 // pa[0] = a; 63 // pa[1] = b; 64 // a.iiArray(pa); // Should throw VerifyError. 65 // } 66 // } 67 68 69 class II { 70 0xCAFEBABE; 71 0; // minor version 72 57; // version 73 [7] { // Constant Pool 74 ; // first element is empty 75 class #5; // #1 at 0x0A 76 class #6; // #2 at 0x0D 77 Utf8 "SourceFile"; // #3 at 0x10 78 Utf8 "II.java"; // #4 at 0x1D 79 Utf8 "II"; // #5 at 0x33 80 Utf8 "java/lang/Object"; // #6 at 0x37 81 } // Constant Pool 82 83 0x0600; // access [ ACC_INTERFACE ] 84 #1;// this_cpx | 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 an interface type. 27 // 28 // // Java program emulating the jcod contents. 29 // interface II { } 30 // 31 // public value final class NoArrayCovIntf { 32 // final int x; 33 // final int y; 34 // 35 // private NoArrayCovIntf() { 36 // x = 0; 37 // y = 0; 38 // } 39 // 40 // public int getX() { return x; } 41 // public int getY() { return y; } 42 // 43 // public String toString() { 44 // return "NoArrayCovIntf: x=" + getX() + " y=" + getY(); 45 // } 46 // 47 // public void iiArray(ii[] oArr) { 48 // System.out.println("In iiArray"); 49 // } 50 // 51 // public static NoArrayCovIntf createNoArrayCovIntf(int x, int y) { 52 // NoArrayCovIntf p = NoArrayCovIntf.default; 53 // p = __WithField(p.x, x); 54 // p = __WithField(p.y, y); 55 // return p; 56 // } 57 // 58 // public static void main(String[] args) { 59 // NoArrayCovIntf a = createNoArrayCovIntf(3, 4); 60 // NoArrayCovIntf b = createNoArrayCovIntf(2, 4); 61 // NoArrayCovIntf pa[] = new NoArrayCovIntf[2]; 62 // pa[0] = a; 63 // pa[1] = b; 64 // a.iiArray(pa); // Should not throw VerifyError. 65 // } 66 // } 67 68 69 class II { 70 0xCAFEBABE; 71 0; // minor version 72 57; // version 73 [7] { // Constant Pool 74 ; // first element is empty 75 class #5; // #1 at 0x0A 76 class #6; // #2 at 0x0D 77 Utf8 "SourceFile"; // #3 at 0x10 78 Utf8 "II.java"; // #4 at 0x1D 79 Utf8 "II"; // #5 at 0x33 80 Utf8 "java/lang/Object"; // #6 at 0x37 81 } // Constant Pool 82 83 0x0600; // access [ ACC_INTERFACE ] 84 #1;// this_cpx |