-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b36
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8085111 | emb-9 | Aleksey Shipilev | P4 | Resolved | Fixed | team |
JDK-8063940 | 8u45 | Aleksey Shipilev | P4 | Resolved | Fixed | b01 |
JDK-8062670 | 8u40 | Aleksey Shipilev | P4 | Resolved | Fixed | b13 |
JDK-8070022 | emb-8u47 | Aleksey Shipilev | P4 | Resolved | Fixed | team |
If you look at the String.contentEquals code, you will see:
public boolean contentEquals(CharSequence cs) {
....
// Argument is a String
if (cs.equals(this))
return true;
// Argument is a generic CharSequence
char v1[] = value;
int n = v1.length;
if (n != cs.length()) {
return false;
}
for (int i = 0; i < n; i++) {
if (v1[i] != cs.charAt(i)) {
return false;
}
}
That is, if we pass a String in, and we mismatch, we do the per-char test as the fallback, which is guaranteed to "false" again.
public boolean contentEquals(CharSequence cs) {
....
// Argument is a String
if (cs.equals(this))
return true;
// Argument is a generic CharSequence
char v1[] = value;
int n = v1.length;
if (n != cs.length()) {
return false;
}
for (int i = 0; i < n; i++) {
if (v1[i] != cs.charAt(i)) {
return false;
}
}
That is, if we pass a String in, and we mismatch, we do the per-char test as the fallback, which is guaranteed to "false" again.
- backported by
-
JDK-8062670 (str) contentEquals checks the String contents twice on mismatch
-
- Resolved
-
-
JDK-8063940 (str) contentEquals checks the String contents twice on mismatch
-
- Resolved
-
-
JDK-8070022 (str) contentEquals checks the String contents twice on mismatch
-
- Resolved
-
-
JDK-8085111 (str) contentEquals checks the String contents twice on mismatch
-
- Resolved
-