String.java (toString): Check for this == null and throw NullPointerException.
authorBryce McKinlay <bryce@albatross.co.nz>
Thu, 1 Jul 1999 19:58:04 +0000 (19:58 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Thu, 1 Jul 1999 19:58:04 +0000 (20:58 +0100)
1999-07-01  Bryce McKinlay  <bryce@albatross.co.nz>
        * java/lang/String.java (toString): Check for this == null and throw
        NullPointerException.

From-SVN: r27895

libjava/ChangeLog
libjava/java/lang/String.java

index 247da09a787767dbd621d4f41acda59fbf69f64e..892665fcccc8fb2d7a93862590912642a69f036e 100644 (file)
@@ -1,3 +1,8 @@
+1999-07-01  Bryce McKinlay  <bryce@albatross.co.nz>
+
+       * java/lang/String.java (toString): Check for this == null and throw
+       NullPointerException.
+
 1999-07-01  Warren Levy  <warrenl@cygnus.com>
 
        * gnu/gcj/convert/BytesToUnicode.java (read): Changed outlength
index 55cc9cd9410bf7da2dd9e7b40118284a20ad2ae8..c1c7c1824d95826a321a25c7e7daa52f8e1eb296 100644 (file)
@@ -115,6 +115,9 @@ public final class String
 
   public String toString ()
   {
+    // because String is final, we actually get this far on a null reference
+    if (this == null)
+      throw new NullPointerException();
     return this;
   }