Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5081785

(enum) Empty enum declartion allowed in non-static context

    XMLWordPrintable

Details

    • 01
    • generic
    • generic

    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();
         
         }

      }

      Attachments

        Issue Links

          Activity

            People

              ahe Peter Ahe
              jsinghsunw Jit Singh (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: