In JavapTask, if one uses the constructors that take a Writer object, they call getPrintWriterforWriter() on the provided value:
private static PrintWriter getPrintWriterForWriter(Writer w) {
if (w == null)
return getPrintWriterForStream(null);
...
private static PrintWriter getPrintWriterForStream(OutputStream s) {
return new PrintWriter(s, true);
}
if the Writer is null, then null is passed to PrintWriter, OutputStreamWriter, and then Writer. Unfortunately, Writer considers this parameter a lock object which cannot be null:
/**
* Creates a new character-stream writer whose critical sections will
* synchronize on the given object.
*
* @param lock
* Object to synchronize on
*/
protected Writer(Object lock) {
if (lock == null) {
throw new NullPointerException();
}
...
and then throws the exception.
Something other than null should be passed in this case.
private static PrintWriter getPrintWriterForWriter(Writer w) {
if (w == null)
return getPrintWriterForStream(null);
...
private static PrintWriter getPrintWriterForStream(OutputStream s) {
return new PrintWriter(s, true);
}
if the Writer is null, then null is passed to PrintWriter, OutputStreamWriter, and then Writer. Unfortunately, Writer considers this parameter a lock object which cannot be null:
/**
* Creates a new character-stream writer whose critical sections will
* synchronize on the given object.
*
* @param lock
* Object to synchronize on
*/
protected Writer(Object lock) {
if (lock == null) {
throw new NullPointerException();
}
...
and then throws the exception.
Something other than null should be passed in this case.