[PATCH] 4741726: allow Object += String

Michael Bailey michaelbailey0 at gmail.com
Wed Jan 30 14:51:24 PST 2008

This is a patch to address a change from JLS 2 to JLS 3 in section
15.26.2 where this statement was removed:

"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."

Object x = "Hi ";
String i = " world";
x += i;     // This should compile under JLS3

Neal Gafter pointed out the spec change and Alex Buckley confirmed
that it was a javac bug.

Attached is a patch that removes the corresponding check.
There should probably be a test put into the TCK.

Michael Bailey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: javac.patch
Type: text/x-patch
Size: 1320 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20080130/3e0c8cde/javac.patch 

More information about the compiler-dev mailing list