Community
Participate
Working Groups
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 */
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.
*** Bug 74226 has been marked as a duplicate of this bug. ***
This very example now compiles and prints 30 at runtime. More advanced scenarii may not work yet.
Fixed (also checked duplicate member enum scenario). Added regression tests: EnumTest#test019-022.
*** Bug 72866 has been marked as a duplicate of this bug. ***
Verified for 3.1M3 with build I200411040100