RFR: 691423 - (str) Missing synchronization in java.lang.String#contentEquals(CharSequence) (original) (raw)

Jim Gish jim.gish at oracle.com
Thu Jul 26 20:38:16 UTC 2012


OK. With that in mind, here's an update where I leave contentEquals( StringBuffer ) in place (adding a clarifying spec), and defer the synchronization as I had it to the contentEquals( CharSequence ) method:

This method

against @@ -999,15 +999,29 @@ * @since 1.4 */ public boolean contentEquals(StringBuffer sb) {

result

the same

represents the

that if the

@@ -1023,16 +1037,13 @@ return false; // Argument is a StringBuffer, StringBuilder if (cs instanceof AbstractStringBuilder) {

On 07/26/2012 04:28 PM, Mike Duigou wrote:

This would appear to be source compatible but not binary compatible. I don't believe we can remove the contentsEqual(StringBuffer) overload. Code compiled against the existing interface would fail to find the CharSequence interface at runtime and fail.

I believe it would be reasonable to add locking on StringBuffer into the contentsEqual(CharSequence) overload. This would make the behaviour consistent between the two invocations which is important because it will not always be possible for developers to tell which overload is being selected. Mike



More information about the core-libs-dev mailing list