clarify Class.isEnum() doc

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 14
    • Affects Version/s: None
    • Component/s: core-libs
    • b05

      Consider:

          enum MyEnum {
              A,
              B { void foo() { } }
          }

      Then:

              MyEnum.A.getClass().isEnum() ==> true
              MyEnum.B.getClass().isEnum()) ==> false

      This is correct and is as specified by JLS 8.9.1. However, it's counterintuitive, as one might reasonably expect enum constants to be instances of the enum class. This isn't the case, as enum constants with method bodies are instances of an anonymous subclass of the enum class, and isEnum() is [correctly] false for such subclasses.

      This might be worth noting in the Class.isEnum() method doc.

            Assignee:
            Joe Darcy
            Reporter:
            Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: