<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Please review the fix for [1] at [2]. Javac was generating incorrect
code for the case when the `+=` operand was applied to Strings and
it is visible for test cases like:<br>
<font size="+1"><tt><br>
</tt><tt>public class Test {</tt><tt><br>
</tt><tt> static int test() {</tt><tt><br>
</tt><tt> System.out.println("evaluated");</tt><tt><br>
</tt><tt> return 0;</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt><br>
</tt><tt> public static void main(String[] args) {</tt><tt><br>
</tt><tt> String[] array = {""};</tt><tt><br>
</tt><tt> array[test()] += "a";</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt>}</tt></font><br>
<br>
the string "evaluated" is printed twice. Some items were missing in
the stack, the solution is to duplicate those missing items plus not
to evaluate the lhs expression twice.<br>
<br>
Thanks in advance for the comments,<br>
Vicente<br>
<br>
Thanks to Aleksey Shipilev for the great regression test.<br>
<br>
[1] <a class="moz-txt-link-freetext" href="https://bugs.openjdk.java.net/browse/JDK-8204322">https://bugs.openjdk.java.net/browse/JDK-8204322</a><br>
[2] <a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~vromero/8204322/webrev.01/">http://cr.openjdk.java.net/~vromero/8204322/webrev.01/</a><br>
<span title="JDK-8148483: JEP 280 Integration"><br>
</span>
</body>
</html>