Community
Participate
Working Groups
The Eclipse Java compiler generates an ENUM$VALUES field even for anonymous enum constant value classes (those that result from enum constants with class bodies). Only the (abstract) enum class actually requires an ENUM$VALUES field in this case - the field in the (derived) enum constant class is invisible and thus unnecessary. The following test class: public enum WithMethods { VALUE { void foo() {}; }; abstract void foo(); } results in two class files being generated: WithMethods.class (for the abstract enum class) and WithMethods$1.class (for the derived enum constant "VALUE" because it has a class body). Invoking "javap -private" on these two classes yields the following results: Correct: public abstract class WithMethods extends java.lang.Enum{ public static final WithMethods VALUE; private static final WithMethods[] ENUM$VALUES; static {}; private WithMethods(java.lang.String, int); abstract void foo(); public static final WithMethods[] values(); public static final WithMethods valueOf(java.lang.String); WithMethods(java.lang.String, int, WithMethods); } Does not need ENUM$VALUES: final class WithMethods$1 extends WithMethods{ private static final WithMethods$1[] ENUM$VALUES; WithMethods$1(java.lang.String, int); void foo(); } Tested on Eclipse Version: 3.1.2 (Build id: M20060118-1600). Earlier versions have the same bug.
Fixed and released in HEAD. Added regression test org.eclipse.jdt.core.tests.compiler.regression.EnumTest.test127
Fixed
Backported to 3.1.x. Same regression test added.
Verified for 3.2 M5 using build I20060215-0010