[cp-patches] [PATCH] Fix PrintStream constructor API differences for null

Pekka Enberg penberg at kernel.org
Sat Jan 22 19:13:40 UTC 2011


2011-01-22  Pekka Enberg <penberg at kernel.org>

	* java/io/PrintStream.java
	(PrintStream): Throw NullPointerException if out or encoding
	is null to be compatible with OpenJDK.
---
 java/io/PrintStream.java |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/java/io/PrintStream.java b/java/io/PrintStream.java
index eaab7c3..72286bf 100644
--- a/java/io/PrintStream.java
+++ b/java/io/PrintStream.java
@@ -181,10 +181,15 @@ public class PrintStream extends FilterOutputStream implements Appendable
    * @param out The <code>OutputStream</code> to write to.
    * @param auto_flush <code>true</code> to flush the stream after every
    * line, <code>false</code> otherwise
+   * @exception NullPointerException If out is null.
    */
   public PrintStream (OutputStream out, boolean auto_flush)
   {
     super (out);
+
+    if (out == null)
+      throw new NullPointerException();
+
     String encoding;
     try {
         encoding = SystemProperties.getProperty("file.encoding");
@@ -213,12 +218,16 @@ public class PrintStream extends FilterOutputStream implements Appendable
    * line, <code>false</code> otherwise
    * @param encoding The name of the character encoding to use for this
    * object.
+   * @exception NullPointerException If out or encoding is null.
    */
   public PrintStream (OutputStream out, boolean auto_flush, String encoding)
     throws UnsupportedEncodingException
   {
     super (out);
 
+    if (out == null || encoding == null)
+      throw new NullPointerException();
+
     new String(new byte[]{0}, encoding);    // check if encoding is supported
     this.encoding = encoding;
     this.auto_flush = auto_flush;
-- 
1.7.1




More information about the Classpath-patches mailing list