Missing trivial optimization in String equals

Martin Grajcar maaartinus at gmail.com
Mon Jan 22 23:14:43 UTC 2018


It looks like when testing equality of Strings, there's no test if the two
arrays are actually the same object. This was impossible before Java 8u20
(as no two strings used to share arrays), but it's well possible with
-XX:+UseStringDeduplication.

Maybe someone here cares...

Regards,
Martin.

http://hg.openjdk.java.net/jdk10/jdk10/jdk/file/777356696811/src/java.base/
share/classes/java/lang/String.java#l1014
http://hg.openjdk.java.net/jdk10/jdk10/jdk/file/777356696811/src/java.base/
share/classes/java/lang/StringLatin1.java#l89
http://hg.openjdk.java.net/jdk10/jdk10/jdk/file/777356696811/src/java.base/
share/classes/java/lang/StringUTF16.java#l258


More information about the jdk-dev mailing list