Enum.hashCode() should return ordinal value for the enum, for better consistency

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P3
    • None
    • Affects Version/s: 9
    • Component/s: core-libs
    • generic

      A DESCRIPTION OF THE REQUEST :
      I discovered, that java.lang.Enum.hashCode() returns default hashCode value.

      It does not contradict with JLS, but it would be more consistent to return Enum.ordinal() as hashCode() value which is unique, by it's definition.

      JUSTIFICATION :
      It does not contradict with JLS, but it would be more consistent to return Enum.ordinal() as hashCode() value which is unique, by it's definition.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Enum.hashCode() should return Enum.ordinal() value
      ACTUAL -
      Enum.hashCode() returns default Object.hashCode() value

            Assignee:
            Stuart Marks
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: