On 22 January 2011 19:13, Pekka Enberg <penb...@kernel.org> wrote: > 2011-01-22 Pekka Enberg <penb...@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 > > >
What is the current behaviour? Does it eventually throw an NPE but just performs a lot of additional computation first? Or does it throw some other error? Or return a bad value? The NPEs should have some message as to what went wrong e.g. "The specified output stream was null.". -- Andrew :-) Free Java Software Engineer Red Hat, Inc. (http://www.redhat.com) Support Free Java! Contribute to GNU Classpath and the OpenJDK http://www.gnu.org/software/classpath http://openjdk.java.net PGP Key: 94EFD9D8 (http://subkeys.pgp.net) Fingerprint: F8EF F1EA 401E 2E60 15FA 7927 142C 2591 94EF D9D8