Name: rmT116609 Date: 03/10/2004
FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux localhost.localdomain 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686
i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
It is possible for a programmer to declare a class that extends the class
java.lang.Enum. The javadoc for the sole constructor says that it is not possible for programmers to call that method directly; it is only for use by code emitted by the compiler. Very specifically, whilst java.lang.Enum can not be final, as the compiler generates code that extends it, it should not be possible for a programmer to extend java.lang.Enum directly in code.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see code example.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An error message from the compiler along the lines of 'it is illegal to subclass
java.lang.Enum directly'.
ACTUAL -
javac compiles the code with no error message.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// Can be a top-level or inner class:
public class EnumExtend extends Enum {
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not subclass java.lang.Enum.
(Incident Review ID: 242871)
======================================================================
- duplicates
-
JDK-5009574 Compiler should prohibit extending java.lang.Enum
- Resolved