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 file contains multiple illegal value type classes that should cause 26 // ClassFormatError exceptions when attempted to be loaded. 27 // 28 // The .jcod classes were originally generated from this Java file and then 29 // modified to cause ClassFormatError or ClassCircularityError exceptions. The 30 // '(bad)' comments in most of the tests show where the modifications were made. 31 // 32 // final __ByValue class Value { 33 // static final Value VT = makeValue(0x01234567); 34 // final int int_v; 35 // Value() { 36 // int_v = 1; 37 // } 38 // static Value makeValue(int x) { 39 // Value v = __MakeDefault Value(); 40 // v = __WithField(v.int_v, x); 41 // return v; 42 // } 43 // } 44 45 ////////////////////////////////////////////////////////////////////// 46 47 // Test that a defaultvalue opcodes causes a VerifyError exception if 48 // -XX:+EnableValhalla is not specified. 49 // 50 class HasDefaultvalue { 51 0xCAFEBABE; 52 0; // minor version 53 55; // version 54 [28] { // Constant Pool 55 ; // first element is empty 56 Method #7 #23; // #1 at 0x0A 57 Field #3 #24; // #2 at 0x0F 58 class #9; // #3 at 0x14 59 int 0x01234567; // #4 at 0x17 60 Method #3 #25; // #5 at 0x1C 61 Field #3 #26; // #6 at 0x21 62 class #27; // #7 at 0x26 63 Utf8 "VT"; // #8 at 0x29 64 Utf8 "HasDefaultvalue"; // #9 at 0x2E 65 Utf8 "ValueTypes"; // #10 at 0x36 66 Utf8 "LHasDefaultvalue;"; // #11 at 0x43 67 Utf8 "int_v"; // #12 at 0x4D 68 Utf8 "I"; // #13 at 0x55 69 Utf8 "<init>"; // #14 at 0x59 70 Utf8 "()V"; // #15 at 0x62 71 Utf8 "Code"; // #16 at 0x68 72 Utf8 "LineNumberTable"; // #17 at 0x6F 73 Utf8 "makeHasDefaultvalue"; // #18 at 0x81 74 Utf8 "(I)LHasDefaultvalue;"; // #19 at 0x8D 75 Utf8 "<clinit>"; // #20 at 0x9A 76 Utf8 "SourceFile"; // #21 at 0xA5 77 Utf8 "HasDefaultvalue.java"; // #22 at 0xB2 78 NameAndType #14 #15; // #23 at 0xBF 79 NameAndType #12 #13; // #24 at 0xC4 80 NameAndType #18 #19; // #25 at 0xC9 81 NameAndType #8 #11; // #26 at 0xCE 82 Utf8 "java/lang/Object"; // #27 at 0xD3 83 } // Constant Pool 84 85 0x0130; // access [ ACC_VALUE ACC_SUPER ACC_FINAL ] 86 #3;// this_cpx 87 #7;// super_cpx 88 89 [0] { // Interfaces 90 } // Interfaces 91 92 [2] { // fields 93 { // Member at 0xF0 94 0x0118; // access 95 #8; // name_cpx 96 #11; // sig_cpx 97 [0] { // Attributes 98 } // Attributes 99 } // Member 100 ; 101 { // Member at 0xF8 102 0x0010; // access [ ACC_FINAL ] 103 #12; // name_cpx 104 #13; // sig_cpx 105 [0] { // Attributes 106 } // Attributes 107 } // Member 108 } // fields 109 110 [3] { // methods 111 { // Member at 0x0102 112 0x0000; // access 113 #14; // name_cpx 114 #15; // sig_cpx 115 [1] { // Attributes 116 Attr(#16, 42) { // Code at 0x010A 117 2; // max_stack 118 1; // max_locals 119 Bytes[10]{ 120 0x2AB700012A04B500; 121 0x02B1; 122 }; 123 [0] { // Traps 124 } // end Traps 125 [1] { // Attributes 126 Attr(#17, 14) { // LineNumberTable at 0x0126 127 [3] { // LineNumberTable 128 0 4; // at 0x0132 129 4 5; // at 0x0136 130 9 6; // at 0x013A 131 } 132 } // end LineNumberTable 133 } // Attributes 134 } // end Code 135 } // Attributes 136 } // Member 137 ; 138 { // Member at 0x013A 139 0x0008; // access 140 #18; // name_cpx 141 #19; // sig_cpx 142 [1] { // Attributes 143 Attr(#16, 44) { // Code at 0x0142 144 2; // max_stack 145 2; // max_locals 146 Bytes[12]{ 147 0xCB00034C2B1ACC00; 148 0x024C2BB0; 149 }; 150 [0] { // Traps 151 } // end Traps 152 [1] { // Attributes 153 Attr(#17, 14) { // LineNumberTable at 0x0160 154 [3] { // LineNumberTable 155 0 8; // at 0x016C 156 4 9; // at 0x0170 157 10 10; // at 0x0174 158 } 159 } // end LineNumberTable 160 } // Attributes 161 } // end Code 162 } // Attributes 163 } // Member 164 ; 165 { // Member at 0x0174 166 0x0008; // access 167 #20; // name_cpx 168 #15; // sig_cpx 169 [1] { // Attributes 170 Attr(#16, 33) { // Code at 0x017C 171 1; // max_stack 172 0; // max_locals 173 Bytes[9]{ 174 0x1204B80005B30006; 175 0xB1; 176 }; 177 [0] { // Traps 178 } // end Traps 179 [1] { // Attributes 180 Attr(#17, 6) { // LineNumberTable at 0x0197 181 [1] { // LineNumberTable 182 0 2; // at 0x01A3 183 } 184 } // end LineNumberTable 185 } // Attributes 186 } // end Code 187 } // Attributes 188 } // Member 189 } // methods 190 191 [2] { // Attributes 192 Attr(#21, 2) { // SourceFile at 0x01A5 193 #22; 194 } // end SourceFile 195 ; 196 Attr(#10, 4) { // ValueTypes at 0x01AD 197 0x00010003; 198 } // end ValueTypes 199 } // Attributes 200 } 201 202 ////////////////////////////////////////////////////////////////////// 203 204 // Test that a withfield opcode causes a VerifyError exception if 205 // -XX:+EnableValhalla is not specified. 206 // 207 class HasWithfield { 208 0xCAFEBABE; 209 0; // minor version 210 55; // version 211 [28] { // Constant Pool 212 ; // first element is empty 213 Method #7 #23; // #1 at 0x0A 214 Field #3 #24; // #2 at 0x0F 215 class #9; // #3 at 0x14 216 int 0x01234567; // #4 at 0x17 217 Method #3 #25; // #5 at 0x1C 218 Field #3 #26; // #6 at 0x21 219 class #27; // #7 at 0x26 220 Utf8 "VT"; // #8 at 0x29 221 Utf8 "HasWithfield"; // #9 at 0x2E 222 Utf8 "ValueTypes"; // #10 at 0x36 223 Utf8 "LHasWithfield;"; // #11 at 0x43 224 Utf8 "int_v"; // #12 at 0x4D 225 Utf8 "I"; // #13 at 0x55 226 Utf8 "<init>"; // #14 at 0x59 227 Utf8 "()V"; // #15 at 0x62 228 Utf8 "Code"; // #16 at 0x68 229 Utf8 "LineNumberTable"; // #17 at 0x6F 230 Utf8 "makeHasWithfield"; // #18 at 0x81 231 Utf8 "(I)LHasWithfield;"; // #19 at 0x8D 232 Utf8 "<clinit>"; // #20 at 0x9A 233 Utf8 "SourceFile"; // #21 at 0xA5 234 Utf8 "HasWithfield.java"; // #22 at 0xB2 235 NameAndType #14 #15; // #23 at 0xBF 236 NameAndType #12 #13; // #24 at 0xC4 237 NameAndType #18 #19; // #25 at 0xC9 238 NameAndType #8 #11; // #26 at 0xCE 239 Utf8 "java/lang/Object"; // #27 at 0xD3 240 } // Constant Pool 241 242 0x0130; // access [ ACC_VALUE ACC_SUPER ACC_FINAL ] 243 #3;// this_cpx 244 #7;// super_cpx 245 246 [0] { // Interfaces 247 } // Interfaces 248 249 [2] { // fields 250 { // Member at 0xF0 251 0x0118; // access 252 #8; // name_cpx 253 #11; // sig_cpx 254 [0] { // Attributes 255 } // Attributes 256 } // Member 257 ; 258 { // Member at 0xF8 259 0x0010; // access [ ACC_FINAL ] 260 #12; // name_cpx 261 #13; // sig_cpx 262 [0] { // Attributes 263 } // Attributes 264 } // Member 265 } // fields 266 267 [3] { // methods 268 { // Member at 0x0102 269 0x0000; // access 270 #14; // name_cpx 271 #15; // sig_cpx 272 [1] { // Attributes 273 Attr(#16, 42) { // Code at 0x010A 274 2; // max_stack 275 1; // max_locals 276 Bytes[10]{ 277 0x2AB700012A04B500; 278 0x02B1; 279 }; 280 [0] { // Traps 281 } // end Traps 282 [1] { // Attributes 283 Attr(#17, 14) { // LineNumberTable at 0x0126 284 [3] { // LineNumberTable 285 0 4; // at 0x0132 286 4 5; // at 0x0136 287 9 6; // at 0x013A 288 } 289 } // end LineNumberTable 290 } // Attributes 291 } // end Code 292 } // Attributes 293 } // Member 294 ; 295 { // Member at 0x013A 296 0x0008; // access 297 #18; // name_cpx 298 #19; // sig_cpx 299 [1] { // Attributes 300 Attr(#16, 44) { // Code at 0x0142 301 2; // max_stack 302 2; // max_locals 303 Bytes[12]{ 304 0xCC00034C2B1ACC00; // Change defaultvalue (oxCB) to withfield (0xCC) 305 0x024C2BB0; 306 }; 307 [0] { // Traps 308 } // end Traps 309 [1] { // Attributes 310 Attr(#17, 14) { // LineNumberTable at 0x0160 311 [3] { // LineNumberTable 312 0 8; // at 0x016C 313 4 9; // at 0x0170 314 10 10; // at 0x0174 315 } 316 } // end LineNumberTable 317 } // Attributes 318 } // end Code 319 } // Attributes 320 } // Member 321 ; 322 { // Member at 0x0174 323 0x0008; // access 324 #20; // name_cpx 325 #15; // sig_cpx 326 [1] { // Attributes 327 Attr(#16, 33) { // Code at 0x017C 328 1; // max_stack 329 0; // max_locals 330 Bytes[9]{ 331 0x1204B80005B30006; 332 0xB1; 333 }; 334 [0] { // Traps 335 } // end Traps 336 [1] { // Attributes 337 Attr(#17, 6) { // LineNumberTable at 0x0197 338 [1] { // LineNumberTable 339 0 2; // at 0x01A3 340 } 341 } // end LineNumberTable 342 } // Attributes 343 } // end Code 344 } // Attributes 345 } // Member 346 } // methods 347 348 [2] { // Attributes 349 Attr(#21, 2) { // SourceFile at 0x01A5 350 #22; 351 } // end SourceFile 352 ; 353 Attr(#10, 4) { // ValueTypes at 0x01AD 354 0x00010003; 355 } // end ValueTypes 356 } // Attributes 357 } // end class HasWithfield