Bug 74851 - [1.5] enum errors in 3.1M1
Summary: [1.5] enum errors in 3.1M1
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal with 2 votes (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 72866 74226 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-09-23 16:02 EDT by Chris Beams CLA
Modified: 2004-11-04 07:20 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Beams CLA 2004-09-23 16:02:33 EDT
The class 'MonthEnum' (complete code below) compiles and runs perfectly using 
jdk1.5 javac/java.

When loading it up into 3.1M1, the editor displays two errors, and fails to 
compile for the same reasons:

1) in the `switch(this)` statement (line 23), 'this' is underlined in red and 
the following error is displayed:
    "case constant must be a char, byte, short, or int instead of MonthEnum"

2) in the `println(JANUARY.getDays())` call, JANUARY is underlined in red, and 
the error displayed reads:
    "JANUARY cannot be resolved"

Compilation/running fails (Unresolved compilation error on #2 above), and I can 
go no further.

Thanks for your attention to this!

- Chris Beams
cbeams@gmail.com


/* begin MonthEnum code */
public enum MonthEnum {
    JANUARY   (30),
    FEBRUARY  (28),
    MARCH     (31),
    APRIL     (30),
    MAY       (31),
    JUNE      (30),
    JULY      (31),
    AUGUST    (31),
    SEPTEMBER (31),
    OCTOBER   (31),
    NOVEMBER  (30),
    DECEMBER  (31);
    
    private final int days;
    
    MonthEnum(int days) {
        this.days = days;
    }
    
    public int getDays() {
    	boolean leapYear = true;
    	switch(this) {
    		case FEBRUARY: if(leapYear) return days+1;
    	}
    	return days;
    }
    
    public static void main(String[] args) {
    	System.out.println(JANUARY.getDays());
    }
    
}
/* end MonthEnum code */
Comment 1 Philipe Mulet CLA 2004-09-23 16:46:30 EDT
We don't support enums yet, but will for sure.
It is a bit confusing as we do parse them completely, but do not process them 
any further.
Comment 2 Kent Johnson CLA 2004-09-24 12:19:41 EDT
*** Bug 74226 has been marked as a duplicate of this bug. ***
Comment 3 Philipe Mulet CLA 2004-10-25 10:26:46 EDT
This very example now compiles and prints 30 at runtime.
More advanced scenarii may not work yet.
Comment 4 Philipe Mulet CLA 2004-10-25 11:16:12 EDT
Fixed (also checked duplicate member enum scenario).
Added regression tests: EnumTest#test019-022.
Comment 5 Frederic Fusier CLA 2004-10-27 10:53:33 EDT
*** Bug 72866 has been marked as a duplicate of this bug. ***
Comment 6 David Audel CLA 2004-11-04 07:20:20 EST
Verified for 3.1M3 with build I200411040100