Bug 127766 - [1.5][compiler] inconsistent treatment of explicit subclasses of Enum
Summary: [1.5][compiler] inconsistent treatment of explicit subclasses of Enum
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.2 RC4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-14 11:33 EST by Adam Kiezun CLA
Modified: 2006-05-11 22:02 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (1.17 KB, patch)
2006-05-08 12:12 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression test (7.91 KB, patch)
2006-05-08 12:12 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2006-02-14 11:33:42 EST
3.2M4

It seems to be disallowed to create explicit, named subclasses of Enum.
But anonymous subclasses are not disallowed. Not sure if this is a bug in the compiler or hole in the spec or just a bizzare feature of the language.

//no error here
Enum e= new Enum("foo", 2){
 public int compareTo(Object o) {
  return 0;
  }            
}

class B extends Enum{ } //error here
Comment 1 Olivier Thomann CLA 2006-05-08 11:49:54 EDT
The first case that doesn't fail to compile reports:
Exception in thread "main" java.lang.VerifyError: (class: X$1, method: <init> signature: (Ljava/lang/String;I)V) Expecting to find unitialized object on stack
	at X.main(X.java:7)

at runtime.
Comment 2 Olivier Thomann CLA 2006-05-08 12:12:00 EDT
Created attachment 40608 [details]
Proposed fix
Comment 3 Olivier Thomann CLA 2006-05-08 12:12:16 EDT
Created attachment 40609 [details]
Regression test
Comment 4 Philipe Mulet CLA 2006-05-10 15:30:13 EDT
Fix looks good. 
+1 for 3.2RC4

Darin/Dani: pls cast your vote. Fix is trivial (exact same check we perform when connecting superclasses, but anonymous use a different codepath which didn't check).
Comment 5 Philipe Mulet CLA 2006-05-10 15:30:35 EDT
Dani - pls  vote
Comment 6 Dani Megert CLA 2006-05-10 15:47:27 EDT
Looked at the patch - approving for 3.2 RC4.
Comment 7 Darin Wright CLA 2006-05-10 15:53:31 EDT
+1
Comment 8 Olivier Thomann CLA 2006-05-10 16:37:54 EDT
Fixed and released in HEAD.
Regression test added in org.eclipse.jdt.core.tests.compiler.regression.EnumTest.test128
Comment 9 Olivier Thomann CLA 2006-05-11 22:02:54 EDT
Verified with I20060511-2000 for 3.2RC4