Bug 78916 - [1.5][compiler] abstract methods in an enum declaration must be implemented for each constant
Summary: [1.5][compiler] abstract methods in an enum declaration must be implemented f...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 77211 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-17 23:47 EST by Olivier Thomann CLA
Modified: 2004-12-14 15:59 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2004-11-17 23:47:20 EST
The following code should report an error:

public enum X {
	A
	;
	
	public abstract void foo();
}
Comment 1 Olivier Thomann CLA 2004-11-17 23:49:04 EST
We report an error, but not the right error.
We report:

----------
1. ERROR in C:\tests_sources\X.java (at line 5)
	public abstract void foo();
	                     ^^^^^
The abstract method foo in type X can only be defined by an abstract class
----------
1 problem (1 error)

Javac reports:
X.java:1: X is not abstract and does not override abstract method foo() in X
public enum X {
       ^
1 error
Comment 2 Philipe Mulet CLA 2004-11-30 10:27:45 EST
Indeed, the following should be accepted:
public enum X {
	A () { public void foo() {} }
	;
	
	public abstract void foo();
}
Comment 3 Philipe Mulet CLA 2004-11-30 16:27:38 EST
Support added. Also tagged enum classfile as abstract when defining abstract
methods (implicit).

Added regression tests: EnumTest#test052-055.
Fixed
Comment 4 Philipe Mulet CLA 2004-12-09 18:26:03 EST
*** Bug 77211 has been marked as a duplicate of this bug. ***
Comment 5 Olivier Thomann CLA 2004-12-14 15:59:14 EST
Verified in 200412140800