commit | 8cd66df3155c9b1e110051f3173f35ac989382a5 | [log] [tgz] |
---|---|---|
author | Goktug Gokdogan <goktug@google.com> | Tue Jun 28 15:46:50 2016 -0700 |
committer | Andrei Korzhevskii <a.korzhevskiy@gmail.com> | Wed Jun 29 07:57:16 2016 +0000 |
tree | 4a8d57c647c697b12e65fd149b73b4c3c1b0afa0 | |
parent | ee508c7d618b14384467ddb407eb882ef472f69e [diff] |
Throw NPE on String.equals when String is null. Change-Id: I82341a243c1c2e90c3f24943c328f4fc8d0e57a9
diff --git a/user/super/com/google/gwt/emul/java/lang/String.java b/user/super/com/google/gwt/emul/java/lang/String.java index 18bd4c0..2489238 100644 --- a/user/super/com/google/gwt/emul/java/lang/String.java +++ b/user/super/com/google/gwt/emul/java/lang/String.java
@@ -410,7 +410,7 @@ public boolean equals(Object other) { // Java equality is translated into triple equality which is a quick to compare strings for // equality without any instanceOf checks. - return this == other; + return checkNotNull(this) == other; } public boolean equalsIgnoreCase(String other) {
diff --git a/user/test/com/google/gwt/emultest/java/lang/StringTest.java b/user/test/com/google/gwt/emultest/java/lang/StringTest.java index 5ed47ee..48194ef 100644 --- a/user/test/com/google/gwt/emultest/java/lang/StringTest.java +++ b/user/test/com/google/gwt/emultest/java/lang/StringTest.java
@@ -351,8 +351,6 @@ assertTrue(hideFromCompiler("").equals("")); assertFalse(hideFromCompiler("").equals(null)); - // TODO: String.equals does not have NPE check -/* try { returnNull().equals("other"); fail(); @@ -370,7 +368,6 @@ } catch (JavaScriptException e) { // expected } -*/ } public void testEqualsIgnoreCase() {