Bug 81262 - [Java 5] Verification error when creating anonymous enum subtypes
Summary: [Java 5] Verification error when creating anonymous enum subtypes
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-15 12:56 EST by Kai-Uwe Maetzel CLA
Modified: 2004-12-15 20:52 EST (History)
0 users

See Also:


Attachments
source/class files (7.86 KB, application/x-zip-compressed)
2004-12-15 12:56 EST, Kai-Uwe Maetzel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kai-Uwe Maetzel CLA 2004-12-15 12:56:03 EST
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.
Comment 1 Kai-Uwe Maetzel CLA 2004-12-15 12:56:54 EST
Created attachment 16656 [details]
source/class files
Comment 2 Olivier Thomann CLA 2004-12-15 15:05:52 EST
I will investigate.
Comment 3 Olivier Thomann CLA 2004-12-15 15:16:44 EST
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.
Comment 4 Olivier Thomann CLA 2004-12-15 15:25:33 EST
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
Comment 5 Olivier Thomann CLA 2004-12-15 15:26:11 EST
If you remove the private constructor, it works.
Comment 6 Olivier Thomann CLA 2004-12-15 15:37:21 EST
  // 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.
Comment 7 Philipe Mulet CLA 2004-12-15 15:49:25 EST
Private constructor emulation is not handling enum extra constructor arguments.
Added test: EnumTest#test059.
Fixed
Comment 8 Olivier Thomann CLA 2004-12-15 20:52:58 EST
Verified in 200412160010