java.io.BufferedReader.read(null,int off,int len) does not throw NPE when len==0 --------------------------------------------------------------------------------
Key: HARMONY-54 URL: http://issues.apache.org/jira/browse/HARMONY-54 Project: Harmony Type: Bug Components: Classlib Reporter: Vladimir Ivanov In java.io package description j2se 1.4.2 specification says, that unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown. But java.io.BufferedReader.read(null,int off,int len) does not throw NPE when len==0 Code to reproduce: import java.io.*; public class test29 { public static void main(String[] args) { char []ch = {}; char [] s = null; BufferedReader toRet = new BufferedReader(new CharArrayReader(ch)); try { System.out.println("read(s, 1, 0)= " + toRet.read(s, 1, 0)); } catch (Exception t) { System.out.println("Exception: " + t); } try { System.out.println("read(s, 1, 1)= " + toRet.read(s, 1, 1)); } catch (Exception t) { System.out.println("Exception: " + t); } } } Steps to Reproduce: 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 2. Compile test29.java using BEA 1.4 javac > javac -d . test29.java 3. Run java using compatible VM (J9) > java -showversion test29 Output: C:\tmp\tmp17>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test29 java version "1.4.2_04" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) Exception: java.lang.NullPointerException Exception: java.lang.NullPointerException C:\tmp\tmp17>C:\harmony\trunk\deploy\jre\bin\java -showversion test29 java version 1.4.2 (subset) (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. read(s, 1, 0)= 0 Exception: java.lang.NullPointerException C:\tmp\tmp17> junit test: ------------------------ BufferedReaderTest.java ------------------------------------------------- import java.io.*; import junit.framework.*; public class BufferedReaderTest extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(BufferedReaderTest.class); } public void testHashCode() { char []ch = {}; BufferedReader toRet = new BufferedReader(new CharArrayReader(ch)); try { toRet.read(null, 1, 0); fail("NullPointerException expected"); } catch (NullPointerException e) { } catch (Exception e) { fail("Unexpected exception: " + e); } } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira