Get the latest tech news

Strings Just Got Faster


In JDK 25, Strings used as keys in immutable Maps can be much faster.

The method linker.downcallHandle(…) takes a symbol and additional parameters to bind a native call to a Java MethodHandle via the Foreign Function & Memory API introduced in JDK 22. Now that we know how String::hashCode works, we can unveil the performance changes made (which consists of a single line of code): the internal field String.hash is marked with the JDK-internal@Stable annotation. There is an unfortunate corner case that the new improvement does not cover: if the hash code of the String happens to be zero, constant folding will not work.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of strings

strings

Related news:

News photo

Python’s new t-strings

News photo

Waymo’s milestone SFO mapping permit comes with strings attached

News photo

Strings Attached: Talking about Russia's agenda for laws in cyberspace