StringBuilder buffer allocation support in compiler

John Rose john.r.rose at
Thu Jun 5 21:16:11 UTC 2014

On Jun 5, 2014, at 12:27 PM, Laszlo Hornyak <laszlo.hornyak at> wrote:

>     public static String sayHello(String name, int age) {
>         return "Hello " + name + ", this is your " + age + "th birthday";
>     }

Try this example (suitably wrapped) with -XX:-OptimizeStringConcat and  -XX:+OptimizeStringConcat.

You should see a substantial difference.  I saw 3x.

Pre-optimizing bytecode shapes (in javac) is usually a bad idea.  Bytecodes are best thought of as a portable representation of programmer intention, not a vehicle for optimization.

— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the compiler-dev mailing list