diff options
author | Pekka Enberg <penberg@kernel.org> | 2011-01-23 13:00:49 +0000 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2011-01-23 13:00:49 +0000 |
commit | 2ca622f0a755dd2cade32f4624fe7ab39096d288 (patch) | |
tree | b295a29ac7099c253d92293385f8a1c3c0a632ed | |
parent | aefd4df2e37bcda279b1f944208b0785c2807cd4 (diff) | |
download | classpath-2ca622f0a755dd2cade32f4624fe7ab39096d288.tar.gz |
Fix PrintStream constructor API differences for null
Reviewed-by: Dr Andrew John Hughes <gnu_andrew@member.fsf.org>
2011-01-23 Pekka Enberg <penberg@kernel.org>
* java/io/PrintStream.java
(PrintStream): Throw NullPointerException if out or encoding
is null to be compatible with OpenJDK.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | java/io/PrintStream.java | 12 |
2 files changed, 18 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2011-01-23 Pekka Enberg <penberg@kernel.org> + + * java/io/PrintStream.java + (PrintStream): Throw NullPointerException if out or encoding + is null to be compatible with OpenJDK. + 2011-01-22 Pekka Enberg <penberg@kernel.org> * native/jni/java-lang/java_lang_VMSystem.c diff --git a/java/io/PrintStream.java b/java/io/PrintStream.java index eaab7c3d4..caa6035cf 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("out is null"); + String encoding; try { encoding = SystemProperties.getProperty("file.encoding"); @@ -213,12 +218,19 @@ 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) + throw new NullPointerException("out is null"); + + if (encoding == null) + throw new NullPointerException("encoding is null"); + new String(new byte[]{0}, encoding); // check if encoding is supported this.encoding = encoding; this.auto_flush = auto_flush; |