April 1st, 20141 2 Java 8 is out for a week or two now, and we all have been puzzled by the tremendous speed improvements of Oracle’s newest coup.
String operations in particular have improved a lot. It’s time to look into the guts of Java and to analyze what’s going on.
Along the way, I also found out why
Pattern.compile() has been deprecated in Java 8. Please stop using it. It’s a big performance penalty.
It took me a while to find out. Only when I looked into the byte code generated by Java 8, I realized what has happened. Oracle has overhauled its
String implementation. Actually they have rewritten it from scratch. They need to retain the backward-compatibility, so it wasn’t that easy to see the trick: they abandoned 16-bit Unicode, replacing it by a more modern encoding. A major step to a more memory-efficient design! The Java community has been longing for this move since ages.