40% performance penalty in enum comparison

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P2
    • 5.0
    • Affects Version/s: 5.0
    • Component/s: core-libs
    • b56
    • generic
    • solaris_8

      I switched two of the int-based enums in javac to use Java enums, and I noted a
      roughly 40% performance penalty. A bit of investigation showed that the problem
      is entirely due to the type-checking code in java.lang.Enum.compareTo(). It
      turns out that the method Class.getSuperclass() is not cheap enough.

      This will be a serious problem for anyone switching to language enums. In fact
      there is no need for the type checking code. Please remove it.

            Assignee:
            Neal Gafter (Inactive)
            Reporter:
            Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: