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

local enums allowed?

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 5.0
    • specification
    • None
    • rc
    • generic
    • solaris_8

      The enum spec is unclear if local enum types should be allowed.

      Logically, a local type is a fresh type each time its declaration is
      executed. That's why local types can never be static and cannot have
      static members.

      Enum types, on the other hand, are always the same type, are always static
      and always have static members.

      This conflict suggests that local enum types should not be allowed.
      However, the spec does not forbid them. But neither does the spec
      provide any semantics for them if they do occur. For example, can a
      local enum type capture final variables from the enclosing scope?

      I recommend local enum types be forbidden.

            gbrachasunw Gilad Bracha (Inactive)
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: