Strings with hash = 0 are not constant foldable

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P2
    • 27
    • Affects Version/s: 25
    • Component/s: 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.

            Assignee:
            Per-Ake Minborg
            Reporter:
            Per-Ake Minborg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: