Optimizing string concatenation [JEP 280]
JEP 280 is an interesting enhancement for the Java platform. Prior to Java 9, string concatenation was translated by javac intoStringBuilder : : append
chains. This was a sub-optimal translation methodology often requiring StringBuilder
presizing.
The enhancement changed the string concatenation bytecode sequence, generated by javac, so that it uses INVOKEDYNAMIC
calls. The purpose of the enhancement was to increase optimization and to support future optimizations without the need to reformat the javac's bytecode.
Note
See JEP 276 for more information on INVOKEDYNAMIC
.
The use of INVOKEDYAMIC
calls to java.lang.invoke.StringConcatFactory
allows us to use a methodology similar to lambda expressions instead of using StringBuilder's step-wise process. This results in more efficient processing of string concatenation.