Use Long.hashCode() instead of int-cast where applicable

XMLWordPrintable

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

      In some JDK classes there's still the following hashCode() implementation:

      long objNum;

      public int hashCode() {
          return (int) objNum;
      }

      This outdated expression should be replaced with Long.hashCode(long) as it

      - uses all bits of the original value, does not discard any information upfront. For example, depending on how you are generating the IDs, the upper bits could change more frequently (or the opposite).

      - does not introduce any bias towards values with more ones (zeros), as it would be the case if the two halves were combined with an OR (AND) operation.

      See also https://stackoverflow.com/a/4045083

            Assignee:
            Sergey Tsypanov
            Reporter:
            Sergey Tsypanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: