[External] : Re: String concatenation order of operations

John Rose john.r.rose at oracle.com
Sun Sep 19 03:33:03 UTC 2021

Yup, S.valueOf is what I meant by toString. Not on primitives of course.

On Sep 18, 2021, at 6:50 PM, Liam Miller-Cushon <cushon at google.com> wrote:

Thanks for the clarification!

I think that's what the patch is doing, then, aside from using String.valueOf instead of Object.toString.

On Sat, Sep 18, 2021 at 6:12 PM Brian Goetz <brian.goetz at oracle.com<mailto:brian.goetz at oracle.com>> wrote:

On 9/18/2021 6:34 PM, Liam Miller-Cushon wrote:
On Wed, Sep 8, 2021 at 3:01 PM Brian Goetz <brian.goetz at oracle.com<mailto:brian.goetz at oracle.com>> wrote:
The natural way to do this is to have the various arguments passed as real stack arguments, causing them to all be evaluated before being pushed through the MH nest

I'm not sure I understand this part. Aren't non-constant arguments already being evaluated and passed as stack arguments to the invokedynamic?

Yes, they are being evaluated, but not toString'ed.  So the compiler generates code to evaluate and push all the arguments, and then the bootstrap does the toString'ing.  That means that arg #2 is evaluated before arg #1 is toString'ed.  For non-string / primitive arguments, the compiler would have to emit `invokevirtual Object::toString` for each argument as it is pushed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210919/24ccd62c/attachment.htm>

More information about the compiler-dev mailing list