harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elena Sayapina (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4405) [classlib][luni] Compatibility: ZipOutputStream.write(null, off, length) exception throwing order differs on Harmony and RI
Date Tue, 10 Jul 2007 09:44:04 GMT
[classlib][luni] Compatibility: ZipOutputStream.write(null, off, length) exception throwing
order differs on Harmony and RI
---------------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-4405
                 URL: https://issues.apache.org/jira/browse/HARMONY-4405
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Elena Sayapina
            Priority: Minor


ZipOutputStream.write(null, offset, length) exception throwing order differs on Harmony and
RI 

This method throws NullPointerException on Harmony if byte array is null and length (or offset)
is negative, but throw IndexOutOfBoundsException on RI. 

For me throwing NullPointerException is more appropriate here (taking into account that both
IndexOutOfBoundsException and 
NullPointerException possible according to Java API Spec), so bug was created only to record
non-bug difference between Harmony and RI.
Please, feel free to close the issue if you agree with this.

Consider the following code:

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipOutputStream;

public class writeTest {

	static byte[] data = null;
	
	public static void main(String[] args) throws IOException {
		File test = new File("test.zip");
		test.createNewFile();
		FileOutputStream out = new FileOutputStream(test.getName());
		ZipOutputStream zipout = new ZipOutputStream(out);
		try {
			zipout.write(data, 0, -2);
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}


Output on Harmony-r552422:

Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r552422, (Jul  2 2007), Windows/ia32/msvc 1310, release build
http://harmony.apache.org

java.lang.NullPointerException


Output on RI:

java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)

java.lang.IndexOutOfBoundsException


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message