Vladimir Ivanov wrote:
I need a consultation: should we follow RI or spec in the case of issue
1100?

I think we shall follow RI for this this problem. Because the behavior of RI is reasonable though it seems that it is not compliant with Spec. If we decide to throw NPE, maybe some use applications would break.

Thanks a lot.

Best regards,
Richard

Thanks, Vladimir


On 8/8/06, Vladimir Ivanov (JIRA) <[EMAIL PROTECTED]> wrote:

[classlib][io] compatibility: Harmony method
DataOutputStream(null).writeBytes("") throws NPE while RI does not

---------------------------------------------------------------------------------------------------------------

                Key: HARMONY-1100
                URL: http://issues.apache.org/jira/browse/HARMONY-1100
            Project: Harmony
         Issue Type: Bug
         Components: Classlib
           Reporter: Vladimir Ivanov


The spec says for the java.io package: "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".
and says nothing about 'null' for DataOutputStream constructor.
So, according to spec the  DataOutputStream(null) should lead to the NPE
instead of writeBytes but according to RI no NPE for constructor and
zero-length string for writeBytes.

=================== test.java =========================
import java.io.DataOutputStream;

public class test {
   public static void main(String args[]) throws Exception {
       System.out.println("res = " + new DataOutputStream(null));
       new DataOutputStream(null).writeBytes("");
       System.out.println("OK");
   }
}
===================================================

Output:
C:\tmp\tmp17>C:\jrockit-jdk1.5.0-windows-ia32\bin\java.exe -cp .
-showversion test
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32,
R25.0.0-75, GC: System optimized over throughput (initial strategy
singleparpar))

res = [EMAIL PROTECTED]
OK

C:\tmp\tmp17>C:\harmony\trunk_0427\deploy\jdk\jre\bin\java.exe -cp .
-showversion test
java version 1.5 (subset)

(c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
res = [EMAIL PROTECTED]
Exception in thread "main" java.lang.NullPointerException
       at java.io.DataOutputStream.writeBytes(DataOutputStream.java:163)
       at test.main(test.java:6)


--
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





--
Richard Liang
China Software Development Lab, IBM


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to