Is an uninitialized object in the stack assignable to a reference type?
陈雨亭
chenyt at cs.sjtu.edu.cn
Sat Jun 3 23:46:13 UTC 2017
Hi, dear all,
One of my tests happens to reveal a verification difference between HotSpot
and J9. J9 rejects the code and says that " Type 'uninitialized' (current
frame, stack[0]) is not assignable to 'reference' type ". HotSpot allows.
Can anyone tell me whether an 'uninitialized' object can be loaded from the
stack (and assigned to a reference).
0: new #2 // class Search
3: new #2 // class Search
6: astore_0
7: ifnonnull 14
10: aload_0
11: ifnonnull 14
Regards,
Yuting
class Search
minor version: 0
major version: 52
flags: ACC_SUPER
Constant pool:
#1 = Utf8 Search
#2 = Class #1 // Search
#3 = Utf8 java/lang/Object
#4 = Class #3 // java/lang/Object
#5 = Utf8 x
#6 = Utf8 LSearch;
#7 = Utf8 y
#8 = Utf8 <init>
#9 = Utf8 ()V
#10 = NameAndType #8:#9 // "<init>":()V
#11 = Methodref #4.#10 // java/lang/Object."<init>":()V
#12 = Utf8 main
#13 = Utf8 ([Ljava/lang/String;)V
#14 = Utf8 Code
#15 = Utf8 StackMapTable
{
public Search x;
descriptor: LSearch;
flags: ACC_PUBLIC
public static Search y;
descriptor: LSearch;
flags: ACC_PUBLIC, ACC_STATIC
public Search();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #11 // Method
java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=1, args_size=1
0: new #2 // class Search
3: new #2 // class Search
6: astore_0
7: ifnonnull 14
10: aload_0
11: ifnonnull 14
14: return
StackMapTable: number_of_entries = 1
frame_type = 255 /* full_frame */
offset_delta = 14
locals = [ uninitialized 3 ]
stack = []
}
J9:
Exception in thread "main" java.lang.VerifyError: JVMVRFY012 stack shape
inconsistent; class=Search, method=main([Ljava/lang/String;)V, pc=11
Exception Details:
Location:
Search.main([Ljava/lang/String;)V @11: JBifnonnull
Reason:
Type 'uninitialized' (current frame, stack[0]) is not assignable to
'reference' type
Current Frame:
bci: @11
flags: { }
locals: { 'uninitialized' }
stack: { 'uninitialized' }
Stackmap Table:
full_frame(@14,{Object[#3]},{})
More information about the hotspot-runtime-dev
mailing list