1 /* 2 * Copyright (c) 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 // This test was generated from this source and then modified: 25 // record recordNames(int x, String y) {} 26 27 // This test has a Record attribute entry that points to a Field instead of a 28 // Utf8. It should result in a ClassFormatError exception. 29 class badRecordAttribute { 30 0xCAFEBABE; 31 65535; // minor version 32 59; // version 33 [69] { // Constant Pool 34 ; // first element is empty 35 Method #2 #3; // #1 at 0x0A 36 class #4; // #2 at 0x0F 37 NameAndType #5 #6; // #3 at 0x12 38 Utf8 "java/lang/Record"; // #4 at 0x17 39 Utf8 "<init>"; // #5 at 0x2A 40 Utf8 "()V"; // #6 at 0x33 41 Field #8 #9; // #7 at 0x39 42 class #10; // #8 at 0x3E 43 NameAndType #11 #12; // #9 at 0x41 44 Utf8 "badRecordAttribute"; // #10 at 0x46 45 Utf8 "x"; // #11 at 0x56 46 Utf8 "I"; // #12 at 0x5A 47 Field #8 #14; // #13 at 0x5E 48 NameAndType #15 #16; // #14 at 0x63 49 Utf8 "y"; // #15 at 0x68 50 Utf8 "Ljava/lang/String;"; // #16 at 0x6C 51 InvokeDynamic 0s #18; // #17 at 0x81 52 NameAndType #19 #20; // #18 at 0x86 53 Utf8 "toString"; // #19 at 0x8B 54 Utf8 "(LbadRecordAttribute;)Ljava/lang/String;"; // #20 at 0x96 55 InvokeDynamic 0s #22; // #21 at 0xBC 56 NameAndType #23 #24; // #22 at 0xC1 57 Utf8 "hashCode"; // #23 at 0xC6 58 Utf8 "(LbadRecordAttribute;)I"; // #24 at 0xD1 59 InvokeDynamic 0s #26; // #25 at 0xE6 60 NameAndType #27 #28; // #26 at 0xEB 61 Utf8 "equals"; // #27 at 0xF0 62 Utf8 "(LbadRecordAttribute;Ljava/lang/Object;)Z"; // #28 at 0xF9 63 Dynamic 1s #30; // #29 at 0x0120 64 NameAndType #31 #32; // #30 at 0x0125 65 Utf8 "\\%pattern\\%recordExample\\%(ILjava\\|lang\\|String\\?)"; // #31 at 0x012A 66 Utf8 "Ljava/lang/runtime/PatternHandle;"; // #32 at 0x015F 67 Utf8 "(ILjava/lang/String;)V"; // #33 at 0x0183 68 Utf8 "Code"; // #34 at 0x019C 69 Utf8 "LineNumberTable"; // #35 at 0x01A3 70 Utf8 "MethodParameters"; // #36 at 0x01B5 71 Utf8 "()Ljava/lang/String;"; // #37 at 0x01C8 72 Utf8 "()I"; // #38 at 0x01DF 73 Utf8 "(Ljava/lang/Object;)Z"; // #39 at 0x01E5 74 Utf8 "()Ljava/lang/runtime/PatternHandle;"; // #40 at 0x01FD 75 Utf8 "SourceFile"; // #41 at 0x0223 76 Utf8 "badRecordAttribute.java"; // #42 at 0x0230 77 Utf8 "Record"; // #43 at 0x0245 78 Utf8 "BootstrapMethods"; // #44 at 0x024E 79 MethodHandle 6b #46; // #45 at 0x0261 80 Method #47 #48; // #46 at 0x0265 81 class #49; // #47 at 0x026A 82 NameAndType #50 #51; // #48 at 0x026D 83 Utf8 "java/lang/runtime/ObjectMethods"; // #49 at 0x0272 84 Utf8 "bootstrap"; // #50 at 0x029A 85 Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/TypeDescriptor;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/Object;"; // #51 at 0x02A6 86 String #53; // #52 at 0x035A 87 Utf8 "x;y"; // #53 at 0x035D 88 MethodHandle 1b #7; // #54 at 0x0363 89 MethodHandle 1b #13; // #55 at 0x0367 90 MethodHandle 6b #57; // #56 at 0x036B 91 Method #58 #59; // #57 at 0x036F 92 class #60; // #58 at 0x0374 93 NameAndType #61 #62; // #59 at 0x0377 94 Utf8 "java/lang/runtime/PatternHandles"; // #60 at 0x037C 95 Utf8 "ofLazyProjection"; // #61 at 0x039F 96 Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/Class;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/runtime/PatternHandle;"; // #62 at 0x03B2 97 Utf8 "InnerClasses"; // #63 at 0x0453 98 class #65; // #64 at 0x0462 99 Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #65 at 0x0465 100 class #67; // #66 at 0x048D 101 Utf8 "java/lang/invoke/MethodHandles"; // #67 at 0x0490 102 Utf8 "Lookup"; // #68 at 0x04B1 103 } // Constant Pool 104 105 0x0030; // access [ ACC_SUPER ACC_FINAL ] 106 #8;// this_cpx 107 #2;// super_cpx 108 109 [0] { // Interfaces 110 } // Interfaces 111 112 [2] { // fields 113 { // Member at 0x04C4 114 0x8012; // access 115 #11; // name_cpx 116 #12; // sig_cpx 117 [0] { // Attributes 118 } // Attributes 119 } // Member 120 ; 121 { // Member at 0x04CC 122 0x8012; // access 123 #15; // name_cpx 124 #16; // sig_cpx 125 [0] { // Attributes 126 } // Attributes 127 } // Member 128 } // fields 129 130 [7] { // methods 131 { // Member at 0x04D6 132 0x0001; // access 133 #5; // name_cpx 134 #33; // sig_cpx 135 [2] { // Attributes 136 Attr(#34, 39) { // Code at 0x04DE 137 2; // max_stack 138 3; // max_locals 139 Bytes[15]{ 140 0x2AB700012A1BB500; 141 0x072A2CB5000DB1; 142 } 143 [0] { // Traps 144 } // end Traps 145 [1] { // Attributes 146 Attr(#35, 6) { // LineNumberTable at 0x04FF 147 [1] { // LineNumberTable 148 0 1; // at 0x050B 149 } 150 } // end LineNumberTable 151 } // Attributes 152 } // end Code 153 ; 154 Attr(#36, 9) { // MethodParameters at 0x050B 155 0x02000B8000000F80; 156 0x00; 157 } // end MethodParameters 158 } // Attributes 159 } // Member 160 ; 161 { // Member at 0x051A 162 0x8001; // access 163 #19; // name_cpx 164 #37; // sig_cpx 165 [1] { // Attributes 166 Attr(#34, 31) { // Code at 0x0522 167 1; // max_stack 168 1; // max_locals 169 Bytes[7]{ 170 0x2ABA00110000B0; 171 } 172 [0] { // Traps 173 } // end Traps 174 [1] { // Attributes 175 Attr(#35, 6) { // LineNumberTable at 0x053B 176 [1] { // LineNumberTable 177 0 1; // at 0x0547 178 } 179 } // end LineNumberTable 180 } // Attributes 181 } // end Code 182 } // Attributes 183 } // Member 184 ; 185 { // Member at 0x0547 186 0x8011; // access 187 #23; // name_cpx 188 #38; // sig_cpx 189 [1] { // Attributes 190 Attr(#34, 31) { // Code at 0x054F 191 1; // max_stack 192 1; // max_locals 193 Bytes[7]{ 194 0x2ABA00150000AC; 195 } 196 [0] { // Traps 197 } // end Traps 198 [1] { // Attributes 199 Attr(#35, 6) { // LineNumberTable at 0x0568 200 [1] { // LineNumberTable 201 0 1; // at 0x0574 202 } 203 } // end LineNumberTable 204 } // Attributes 205 } // end Code 206 } // Attributes 207 } // Member 208 ; 209 { // Member at 0x0574 210 0x8011; // access 211 #27; // name_cpx 212 #39; // sig_cpx 213 [1] { // Attributes 214 Attr(#34, 32) { // Code at 0x057C 215 2; // max_stack 216 2; // max_locals 217 Bytes[8]{ 218 0x2A2BBA00190000AC; 219 } 220 [0] { // Traps 221 } // end Traps 222 [1] { // Attributes 223 Attr(#35, 6) { // LineNumberTable at 0x0596 224 [1] { // LineNumberTable 225 0 1; // at 0x05A2 226 } 227 } // end LineNumberTable 228 } // Attributes 229 } // end Code 230 } // Attributes 231 } // Member 232 ; 233 { // Member at 0x05A2 234 0x8001; // access 235 #11; // name_cpx 236 #38; // sig_cpx 237 [1] { // Attributes 238 Attr(#34, 29) { // Code at 0x05AA 239 1; // max_stack 240 1; // max_locals 241 Bytes[5]{ 242 0x2AB40007AC; 243 } 244 [0] { // Traps 245 } // end Traps 246 [1] { // Attributes 247 Attr(#35, 6) { // LineNumberTable at 0x05C1 248 [1] { // LineNumberTable 249 0 1; // at 0x05CD 250 } 251 } // end LineNumberTable 252 } // Attributes 253 } // end Code 254 } // Attributes 255 } // Member 256 ; 257 { // Member at 0x05CD 258 0x8001; // access 259 #15; // name_cpx 260 #37; // sig_cpx 261 [1] { // Attributes 262 Attr(#34, 29) { // Code at 0x05D5 263 1; // max_stack 264 1; // max_locals 265 Bytes[5]{ 266 0x2AB4000DB0; 267 } 268 [0] { // Traps 269 } // end Traps 270 [1] { // Attributes 271 Attr(#35, 6) { // LineNumberTable at 0x05EC 272 [1] { // LineNumberTable 273 0 1; // at 0x05F8 274 } 275 } // end LineNumberTable 276 } // Attributes 277 } // end Code 278 } // Attributes 279 } // Member 280 ; 281 { // Member at 0x05F8 282 0x0009; // access 283 #31; // name_cpx 284 #40; // sig_cpx 285 [1] { // Attributes 286 Attr(#34, 27) { // Code at 0x0600 287 1; // max_stack 288 0; // max_locals 289 Bytes[3]{ 290 0x121DB0; 291 } 292 [0] { // Traps 293 } // end Traps 294 [1] { // Attributes 295 Attr(#35, 6) { // LineNumberTable at 0x0615 296 [1] { // LineNumberTable 297 0 1; // at 0x0621 298 } 299 } // end LineNumberTable 300 } // Attributes 301 } // end Code 302 } // Attributes 303 } // Member 304 } // methods 305 306 [4] { // Attributes 307 Attr(#41, 2) { // SourceFile at 0x0623 308 #42; 309 } // end SourceFile 310 ; 311 Attr(#44, 24) { // BootstrapMethods at 0x063F 312 [2] { // bootstrap_methods 313 { // bootstrap_method 314 #45; // bootstrap_method_ref 315 [4] { // bootstrap_arguments 316 #8; // at 0x064D 317 #52; // at 0x064F 318 #54; // at 0x0651 319 #55; // at 0x0653 320 } // bootstrap_arguments 321 } // bootstrap_method 322 ; 323 { // bootstrap_method 324 #56; // bootstrap_method_ref 325 [3] { // bootstrap_arguments 326 #8; // at 0x0659 327 #54; // at 0x065B 328 #55; // at 0x065D 329 } // bootstrap_arguments 330 } // bootstrap_method 331 } 332 } // end BootstrapMethods 333 ; 334 Attr(#43, 14) { // Record at 0x062B 335 0x0002000B000D0000; // Change cp index from C (Utf8) to D (Field) 336 0x000F00100000; 337 } // end Record 338 ; 339 Attr(#63, 10) { // InnerClasses at 0x065D 340 [1] { // InnerClasses 341 #64 #66 #68 25; // at 0x066D 342 } 343 } // end InnerClasses 344 } // Attributes 345 } // end class badRecordAttribute