Community
Participate
Working Groups
I200412142000 The attached source/class files cause a VM verification error when executing Worker.main. When commenting lines 5 - 9 and uncommenting line 10 in Day.java, the problem goes away. Pls check whether this is a compiler problem.
Created attachment 16656 [details] source/class files
I will investigate.
Indeed this seems to be a bug in the inner emulation for enum types. A synthetic constructor is created with the following contents: // Method descriptor #144 (Ljava/lang/String;ILp/Day;)V // Stack: 1, Locals: 4 synthetic p.Day(String arg, int arg, Day arg); 0 aload_0 1 invokespecial #43 <Method p/Day.<init>(Ljava/lang/String;I)V> 4 return Line numbers: [pc: 0, line: 21] There is a missing int and string on the stack prior to the invokespecial call.
Simple test case:` public enum Day { MONDAY { public void foo() { } }; private Day() { } public static void main(String[] args) { } } Error is: Exception in thread "main" java.lang.VerifyError: (class: Day, method: <init> signature: (Ljava/lang/String;ILDay;)V) Expecting to find integer on stack
If you remove the private constructor, it works.
// Method descriptor #56 (Ljava/lang/String;ILDay;)V // Stack: 1, Locals: 4 synthetic Day(String arg, int arg, Day arg); 0 aload_0 1 invokespecial #57 <Method Day.<init>(Ljava/lang/String;I)V> 4 return Line numbers: [pc: 0, line: 8] Missing argument on stack.
Private constructor emulation is not handling enum extra constructor arguments. Added test: EnumTest#test059. Fixed
Verified in 200412160010