Bug 184102 - [1.6][compiler] Inconsistent stackmap frame generated for static initializer of enums containing overridden methods
Summary: [1.6][compiler] Inconsistent stackmap frame generated for static initializer ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-25 15:47 EDT by Dave Liu CLA
Modified: 2007-04-27 10:36 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Liu CLA 2007-04-25 15:47:12 EDT
Compiling the following enum using Eclipse 3.3 M6:

public enum TestEnum {
	C { @Override public boolean test() { return true; } };

	static {
		for (int i = 0; i < 1; i++) {
		}
	}
	
	public boolean test() {
		return false;
	}
}

Produces the following static initializer with an incorrect stackmap:

static {};
  Code:
   Stack=6, Locals=1, Args_size=0
   0:   new     #12; //class TestEnum$1
   3:   dup
   4:   ldc     #14; //String C
   6:   iconst_0
   7:   invokespecial   #15; //Method TestEnum$1."<init>":(Ljava/lang/String;I)V
   10:  putstatic       #19; //Field C:LTestEnum;
   13:  iconst_1
   14:  anewarray       #1; //class TestEnum
   17:  dup
   18:  iconst_0
   19:  getstatic       #19; //Field C:LTestEnum;
   22:  aastore
   23:  putstatic       #21; //Field ENUM$VALUES:[LTestEnum;
   26:  iconst_0
   27:  istore_0
   28:  goto    34
   31:  iinc    0, 1
   34:  iload_0
   35:  iconst_1
   36:  if_icmplt       31
   39:  return
  LineNumberTable: 
   line 3: 0
   line 6: 26
   line 2: 39

  LocalVariableTable: 
   Start  Length  Slot  Name   Signature
   28      11      0    i       I

  StackMapTable: number_of_entries = 2
   frame_type = 255 /* full_frame */
     offset_delta = 31
     locals = [ int ]
     stack = [ uninitialized 0, uninitialized 0 ]
   frame_type = 255 /* full_frame */
     offset_delta = 2
     locals = [ int ]
     stack = [ uninitialized 0, uninitialized 0 ]

This stackmap fails to verify:

bin> java -XX:-FailOverToOldVerifier -classpath . TestEnum
Exception in thread "main" java.lang.VerifyError: Inconsistent stackmap frames at branch target 34 in method TestEnum.<clinit>()V at offset 28

If the overridden method "test" is removed from "C", then the problem disappears.
Comment 1 Olivier Thomann CLA 2007-04-25 22:10:00 EDT
Thanks for the report.
Reproduced. Fix under testing.
Comment 2 Olivier Thomann CLA 2007-04-25 22:51:04 EDT
Released for 3.3M7.
Added regression tests org.eclipse.jdt.core.tests.compiler.regression.StackMapAttributeTest.test033()
org.eclipse.jdt.core.tests.compiler.regression.StackMapAttributeTest.test034()
Comment 3 David Audel CLA 2007-04-27 10:36:28 EDT
Verified for 3.3 M7 using build I20070427-0010