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 // This .jcod test was derived from the following Java program. In the .jcod 26 // file, The first opcode was changed to an illegal value to cause a 'bad 27 // instruction' VerifyError exception. Also, the stack map table was changed 28 // so that it contains an illegal verification type. The error occurred when 29 // the verifier tried to print the stack map table as part of the 'bad 30 // instruction' VerifyError exception. 31 // 32 // public class badStackMapTabe extends java.lang.Throwable { 33 // 34 // public static void m(int I, String s, long l, Object o) { 35 // try { 36 // if (I == l) { 37 // System.out.println("x"); 38 // } 39 // } catch (Exception e) { 40 // System.out.println("y"); 41 // } 42 // } 43 // 44 // public static void main(String argv[]) { 45 // badStackMapTabe.m(5, "hi", 6, "x"); 46 // } 47 // } 48 49 50 class badStackMapTable { 51 0xCAFEBABE; 52 0; // minor version 53 55; // version 54 [42] { // Constant Pool 55 ; // first element is empty 56 Method #12 #24; // #1 at 0x0A 57 Field #25 #26; // #2 at 0x0F 58 String #27; // #3 at 0x14 59 Method #28 #29; // #4 at 0x17 60 class #30; // #5 at 0x1C 61 String #31; // #6 at 0x1F 62 String #32; // #7 at 0x22 63 long 0x0000000000000006;; // #8 at 0x25 64 Method #11 #33; // #10 at 0x2E 65 class #34; // #11 at 0x33 66 class #35; // #12 at 0x36 67 Utf8 "<init>"; // #13 at 0x39 68 Utf8 "()V"; // #14 at 0x42 69 Utf8 "Code"; // #15 at 0x48 70 Utf8 "LineNumberTable"; // #16 at 0x4F 71 Utf8 "m"; // #17 at 0x61 72 Utf8 "(ILjava/lang/String;JLjava/lang/Object;)V"; // #18 at 0x65 73 Utf8 "StackMapTable"; // #19 at 0x91 74 Utf8 "main"; // #20 at 0xA1 75 Utf8 "([Ljava/lang/String;)V"; // #21 at 0xA8 76 Utf8 "SourceFile"; // #22 at 0xC1 77 Utf8 "badStackMapTable.java"; // #23 at 0xCE 78 NameAndType #13 #14; // #24 at 0xDA 79 class #36; // #25 at 0xDF 80 NameAndType #37 #38; // #26 at 0xE2 81 Utf8 "x"; // #27 at 0xE7 82 class #39; // #28 at 0xEB 83 NameAndType #40 #41; // #29 at 0xEE 84 Utf8 "java/lang/Exception"; // #30 at 0xF3 85 Utf8 "y"; // #31 at 0x0109 86 Utf8 "hi"; // #32 at 0x010D 87 NameAndType #17 #18; // #33 at 0x0112 88 Utf8 "badStackMapTable"; // #34 at 0x0117 89 Utf8 "java/lang/Throwable"; // #35 at 0x011E 90 Utf8 "java/lang/System"; // #36 at 0x0134 91 Utf8 "out"; // #37 at 0x0147 92 Utf8 "Ljava/io/PrintStream;"; // #38 at 0x014D 93 Utf8 "java/io/PrintStream"; // #39 at 0x0165 94 Utf8 "println"; // #40 at 0x017B 95 Utf8 "(Ljava/lang/String;)V"; // #41 at 0x0185 96 } // Constant Pool 97 98 0x0021; // access [ ACC_PUBLIC ACC_SUPER ] 99 #11;// this_cpx 100 #12;// super_cpx 101 102 [0] { // Interfaces 103 } // Interfaces 104 105 [0] { // fields 106 } // fields 107 108 [3] { // methods 109 { // Member at 0x01A9 110 0x0001; // access 111 #13; // name_cpx 112 #14; // sig_cpx 113 [1] { // Attributes 114 Attr(#15, 29) { // Code at 0x01B1 115 1; // max_stack 116 1; // max_locals 117 Bytes[5]{ 118 0x2AB70001B1; 119 }; 120 [0] { // Traps 121 } // end Traps 122 [1] { // Attributes 123 Attr(#16, 6) { // LineNumberTable at 0x01C8 124 [1] { // LineNumberTable 125 0 1; // at 0x01D4 126 } 127 } // end LineNumberTable 128 } // Attributes 129 } // end Code 130 } // Attributes 131 } // Member 132 ; 133 { // Member at 0x01D4 134 0x0009; // access 135 #17; // name_cpx 136 #18; // sig_cpx 137 [1] { // Attributes 138 Attr(#15, 95) { // Code at 0x01DC 139 4; // max_stack 140 6; // max_locals 141 Bytes[29]{ 142 0xF88520949A000BB2; // Create an illegal opcode by changing 0x1A to 0xF8 143 0x00021203B60004A7; 144 0x000D3A05B2000212; 145 0x06B60004B1; 146 }; 147 [1] { // Traps 148 0 15 18 5; // at 0x0211 149 } // end Traps 150 [2] { // Attributes 151 Attr(#16, 26) { // LineNumberTable at 0x0213 152 [6] { // LineNumberTable 153 0 5; // at 0x021F 154 7 6; // at 0x0223 155 15 10; // at 0x0227 156 18 8; // at 0x022B 157 20 9; // at 0x022F 158 28 11; // at 0x0233 159 } 160 } // end LineNumberTable 161 ; 162 Attr(#19, 8) { // StackMapTable at 0x0233 163 [3] { // 164 15b; // same_frame 165 66b, [1]z{9b,5}; // Create an invalid verification type by changing 7b to 9b 166 9b; // same_frame 167 } 168 } // end StackMapTable 169 } // Attributes 170 } // end Code 171 } // Attributes 172 } // Member 173 ; 174 { // Member at 0x0241 175 0x0009; // access 176 #20; // name_cpx 177 #21; // sig_cpx 178 [1] { // Attributes 179 Attr(#15, 40) { // Code at 0x0249 180 5; // max_stack 181 1; // max_locals 182 Bytes[12]{ 183 0x0812071400081203; 184 0xB8000AB1; 185 }; 186 [0] { // Traps 187 } // end Traps 188 [1] { // Attributes 189 Attr(#16, 10) { // LineNumberTable at 0x0267 190 [2] { // LineNumberTable 191 0 14; // at 0x0273 192 11 15; // at 0x0277 193 } 194 } // end LineNumberTable 195 } // Attributes 196 } // end Code 197 } // Attributes 198 } // Member 199 } // methods 200 201 [1] { // Attributes 202 Attr(#22, 2) { // SourceFile at 0x0279 203 #23; 204 } // end SourceFile 205 } // Attributes 206 } // end class badStackMapTable