changeset 10858:bb9384929769

8060485: (str) contentEquals checks the String contents twice on mismatch Reviewed-by: martin, chegar, alanb
author shade
date Tue, 14 Oct 2014 19:35:03 +0200
parents b63e31c78326
children d1b684867fe0
files src/java.base/share/classes/java/lang/String.java
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/String.java	Tue Oct 14 23:22:00 2014 -0700
+++ b/src/java.base/share/classes/java/lang/String.java	Tue Oct 14 19:35:03 2014 +0200
@@ -1045,8 +1045,9 @@
             }
         }
         // Argument is a String
-        if (cs.equals(this))
-            return true;
+        if (cs instanceof String) {
+            return equals(cs);
+        }
         // Argument is a generic CharSequence
         char v1[] = value;
         int n = v1.length;