diff --git a/classpath/java/io/PrintStream.java b/classpath/java/io/PrintStream.java index 1e21d86ed3..37c141bb03 100644 --- a/classpath/java/io/PrintStream.java +++ b/classpath/java/io/PrintStream.java @@ -23,7 +23,7 @@ public class PrintStream extends OutputStream { } public void print(Object o) { - print(o.toString()); + print(String.valueOf(o)); } public void print(char c) { diff --git a/classpath/java/lang/String.java b/classpath/java/lang/String.java index 3c72ee92e3..283e4b7248 100644 --- a/classpath/java/lang/String.java +++ b/classpath/java/lang/String.java @@ -379,7 +379,7 @@ public final class String implements Comparable { public native String intern(); public static String valueOf(Object s) { - return s.toString(); + return s == null ? "null" : s.toString(); } public static String valueOf(boolean v) {