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

Strings with hash = 0 are not constant foldable

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P2 P2
    • 26
    • 25
    • core-libs

      If the `String.hash` field is zero (i.e. its default value), the `@Stable` annotated field is not trusted. Eventhough `String.hashIsZero` is also `@Stable`, the VM cannot constant fold Sting::hashCode with hash = 0 as the VM first checks the `hash` value. For example `"".hashCode()` is not trusted.

      We should refactor String to trust all hash values.

      A benchmark that reproduces the problem is attached.

            pminborg Per-Ake Minborg
            pminborg Per-Ake Minborg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: