1 /*
  2  * Copyright (c) 2022, 2024, 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 is an abstract class that cannot be a super class for value classes
 26 // because ACC_IDENTITY is set in its class access flags.
 27 // It's based on the following source:
 28 /*
 29 public abstract class NonPVSuper {
 30 
 31     static int x = 3;
 32 
 33     public static void meth() {
 34         System.out.println("hi");
 35     }
 36 }
 37 */
 38 class NonPVSuper {
 39   0xCAFEBABE;
 40   0; // minor version
 41   66; // version
 42   [33] { // Constant Pool
 43     ; // first element is empty
 44     Method #2 #3; // #1     at 0x0A
 45     class #4; // #2     at 0x0F
 46     NameAndType #5 #6; // #3     at 0x12
 47     Utf8 "java/lang/Object"; // #4     at 0x17
 48     Utf8 "<init>"; // #5     at 0x2A
 49     Utf8 "()V"; // #6     at 0x33
 50     Field #8 #9; // #7     at 0x39
 51     class #10; // #8     at 0x3E
 52     NameAndType #11 #12; // #9     at 0x41
 53     Utf8 "java/lang/System"; // #10     at 0x46
 54     Utf8 "out"; // #11     at 0x59
 55     Utf8 "Ljava/io/PrintStream;"; // #12     at 0x5F
 56     String #14; // #13     at 0x77
 57     Utf8 "hi"; // #14     at 0x7A
 58     Method #16 #17; // #15     at 0x7F
 59     class #18; // #16     at 0x84
 60     NameAndType #19 #20; // #17     at 0x87
 61     Utf8 "java/io/PrintStream"; // #18     at 0x8C
 62     Utf8 "println"; // #19     at 0xA2
 63     Utf8 "(Ljava/lang/String;)V"; // #20     at 0xAC
 64     Field #22 #23; // #21     at 0xC4
 65     class #24; // #22     at 0xC9
 66     NameAndType #25 #26; // #23     at 0xCC
 67     Utf8 "NonPVSuper"; // #24     at 0xD1
 68     Utf8 "x"; // #25     at 0xDE
 69     Utf8 "I"; // #26     at 0xE2
 70     Utf8 "Code"; // #27     at 0xE6
 71     Utf8 "LineNumberTable"; // #28     at 0xED
 72     Utf8 "meth"; // #29     at 0xFF
 73     Utf8 "<clinit>"; // #30     at 0x0106
 74     Utf8 "SourceFile"; // #31     at 0x0111
 75     Utf8 "NonPVSuper.java"; // #32     at 0x011E
 76   } // Constant Pool
 77 
 78   0x0421; // access [ ACC_PUBLIC ACC_IDENTITY ACC_ABSTRACT ]
 79   #22;// this_cpx
 80   #2;// super_cpx
 81 
 82   [0] { // Interfaces
 83   } // Interfaces
 84 
 85   [1] { // Fields
 86     {  // field at 0x013A
 87       0x0008; // access
 88       #25; // name_index       : x
 89       #26; // descriptor_index : I
 90       [0] { // Attributes
 91       } // Attributes
 92     }
 93   } // Fields
 94 
 95   [3] { // Methods
 96     {  // method at 0x0144
 97       0x0001; // access
 98       #5; // name_index       : <init>
 99       #6; // descriptor_index : ()V
100       [1] { // Attributes
101         Attr(#27, 29) { // Code at 0x014C
102           1; // max_stack
103           1; // max_locals
104           Bytes[5]{
105             0x2AB70001B1;
106           }
107           [0] { // Traps
108           } // end Traps
109           [1] { // Attributes
110             Attr(#28, 6) { // LineNumberTable at 0x0163
111               [1] { // line_number_table
112                 0  2; //  at 0x016F
113               }
114             } // end LineNumberTable
115           } // Attributes
116         } // end Code
117       } // Attributes
118     }
119     ;
120     {  // method at 0x016F
121       0x0009; // access
122       #29; // name_index       : meth
123       #6; // descriptor_index : ()V
124       [1] { // Attributes
125         Attr(#27, 37) { // Code at 0x0177
126           2; // max_stack
127           0; // max_locals
128           Bytes[9]{
129             0xB20007120DB6000F;
130             0xB1;
131           }
132           [0] { // Traps
133           } // end Traps
134           [1] { // Attributes
135             Attr(#28, 10) { // LineNumberTable at 0x0192
136               [2] { // line_number_table
137                 0  7; //  at 0x019E
138                 8  8; //  at 0x01A2
139               }
140             } // end LineNumberTable
141           } // Attributes
142         } // end Code
143       } // Attributes
144     }
145     ;
146     {  // method at 0x01A2
147       0x0008; // access
148       #30; // name_index       : <clinit>
149       #6; // descriptor_index : ()V
150       [1] { // Attributes
151         Attr(#27, 29) { // Code at 0x01AA
152           1; // max_stack
153           0; // max_locals
154           Bytes[5]{
155             0x06B30015B1;
156           }
157           [0] { // Traps
158           } // end Traps
159           [1] { // Attributes
160             Attr(#28, 6) { // LineNumberTable at 0x01C1
161               [1] { // line_number_table
162                 0  4; //  at 0x01CD
163               }
164             } // end LineNumberTable
165           } // Attributes
166         } // end Code
167       } // Attributes
168     }
169   } // Methods
170 
171   [1] { // Attributes
172     Attr(#31, 2) { // SourceFile at 0x01CF
173       #32;
174     } // end SourceFile
175   } // Attributes
176 } // end class NonPVSuper
177 
178 
179 // Dot is a value class that tries to inherit from a super class (NonPVSuper)
180 // that has access flag ACC_IDENTITY set.
181 // Dot is based on the following source:
182 /*
183 public value final class Dot extends NonPVSuper {
184     int x = 3;
185 
186     public int getX() {
187         return x;
188     }
189 }
190 */
191 class Dot {
192   0xCAFEBABE;
193   0; // minor version
194   66; // version
195   [18] { // Constant Pool
196     ; // first element is empty
197     class #2; // #1     at 0x0A
198     Utf8 "Dot"; // #2     at 0x0D
199     Field #1 #4; // #3     at 0x13
200     NameAndType #5 #6; // #4     at 0x18
201     Utf8 "x"; // #5     at 0x1D
202     Utf8 "I"; // #6     at 0x21
203     class #8; // #7     at 0x25
204     Utf8 "NonPVSuper"; // #8     at 0x28
205     Utf8 "getX"; // #9     at 0x35
206     Utf8 "()I"; // #10     at 0x3C
207     Utf8 "Code"; // #11     at 0x42
208     Utf8 "LineNumberTable"; // #12     at 0x49
209     Utf8 "<vnew>"; // #13     at 0x5B
210     Utf8 "()LDot;"; // #14     at 0x64
211     Utf8 "SourceFile"; // #15     at 0x6E
212     Utf8 "Dot.java"; // #16     at 0x7B
213     Utf8 "Preload"; // #17     at 0x86
214   } // Constant Pool
215 
216   0x0051; // access [ ACC_VALUE ACC_PUBLIC ACC_FINAL ]
217   #1;// this_cpx
218   #7;// super_cpx
219 
220   [0] { // Interfaces
221   } // Interfaces
222 
223   [1] { // Fields
224     {  // field at 0x9A
225       0x0010; // access
226       #5; // name_index       : x
227       #6; // descriptor_index : I
228       [0] { // Attributes
229       } // Attributes
230     }
231   } // Fields
232 
233   [2] { // Methods
234     {  // method at 0xA4
235       0x0001; // access
236       #9; // name_index       : getX
237       #10; // descriptor_index : ()I
238       [1] { // Attributes
239         Attr(#11, 29) { // Code at 0xAC
240           1; // max_stack
241           1; // max_locals
242           Bytes[5]{
243             0x2AB40003AC;
244           }
245           [0] { // Traps
246           } // end Traps
247           [1] { // Attributes
248             Attr(#12, 6) { // LineNumberTable at 0xC3
249               [1] { // line_number_table
250                 0  5; //  at 0xCF
251               }
252             } // end LineNumberTable
253           } // Attributes
254         } // end Code
255       } // Attributes
256     }
257     ;
258     {  // method at 0xCF
259       0x0009; // access
260       #13; // name_index       : <vnew>
261       #14; // descriptor_index : ()LDot;
262       [1] { // Attributes
263         Attr(#11, 41) { // Code at 0xD7
264           2; // max_stack
265           1; // max_locals
266           Bytes[13]{
267             0xCB00014B062A5FCC;
268             0x00034B2AB0;
269           }
270           [0] { // Traps
271           } // end Traps
272           [1] { // Attributes
273             Attr(#12, 10) { // LineNumberTable at 0xF6
274               [2] { // line_number_table
275                 0  1; //  at 0x0102
276                 4  2; //  at 0x0106
277               }
278             } // end LineNumberTable
279           } // Attributes
280         } // end Code
281       } // Attributes
282     }
283   } // Methods
284 
285   [2] { // Attributes
286     Attr(#15, 2) { // SourceFile at 0x0108
287       #16;
288     } // end SourceFile
289     ;
290     Attr(#17, 4) { // Preload at 0x0110
291       0x00010001;
292     } // end Preload
293   } // Attributes
294 } // end class Dot