Relates :
|
FULL PRODUCT VERSION : A DESCRIPTION OF THE PROBLEM : JLS 2: 15.26.2 begins: "All compound assignment operators require both operands to be of primitive type, except for +=, which allows the right-hand operand to be of any type if the left-hand operand is of type String. A compound assignment expression of the form E1 op= E2 is equivalent to E1 = (T)((E1) op (E2)), where T is the type of E1, except that E1 is evaluated only once. Note that the implied cast to type T may be either an identity conversion (��5.1.1) or a narrowing primitive conversion" while JLS 3: 15.26.2 begins with only: "A compound assignment expression of the form E1 op= E2 is equivalent to E1 = (T)((E1) op (E2)), where T is the type of E1, except that E1 is evaluated only once" In addition to the intended purpose of the change (allowing primitive wrappers to be used), this would also allow: Object o = new Object(); o += "test"; since: Object o = new Object(); o = (Object)((o) + ("test")); is legal. The former is not accepted by javac. REPRODUCIBILITY : This bug can be reproduced always.