JDK-5081785 : (enum) Empty enum declartion allowed in non-static context
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-08-03
  • Updated: 2017-05-16
  • Resolved: 2004-09-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0u1 01Fixed
Related Reports
Relates :  
Relates :  
Description
Empty enum declartions are allowed where other static declarations are not

Tried on Tiger-Beta3-Build 59, solaris

Please See the code below:-

/**Empty enum declarations are allowed where other
  *static declarations are not allowed.
  */
     

import java.util.*;

class B {
  
}

class A {

   enum COLOR{RED, GREEN};
   
   public B check() {
     //enum CHECK{}; ->compilation error enum types must not be local
     return new B() {
                      //static int k =0;   -> Compilation error static inside inner class 
                      //public static void show() {}  -> compilation error static inside inner class
                      enum STRENGTH{};  // compiles silently  
                      //enum STRENGTH{HARD,SOFT}; // gives compilation error non static variable this cannot be refrenced from a static context 
                     };         
   }
}

public class Test16 {
   
   public void assertion() {
     A ref_A = new A();
     B ref_B = ref_A.check();
   }
   
   public static void main(String args[]) {
     Test16 ref = new Test16();
     ref.assertion();
   
   }

}

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.5.0_01 mustang FIXED IN: 1.5.0_01 INTEGRATED IN: 1.5.0_01
26-09-2004

EVALUATION The problem is the enum STRENGTH. It appears to be a bug. However, an empty enum is virtually useless so we should be able to fix this after Tiger. ###@###.### 2004-08-03
03-08-2004