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-4337) [classlib][luni] Compatibility: InputStream.write(null, offset, len) exception throwing order differs on Harmony and RI if offset is negative
Date Wed, 04 Jul 2007 12:10:04 GMT
[classlib][luni] Compatibility: InputStream.write(null, offset, len) exception throwing order
differs on Harmony and RI if offset is negative
---------------------------------------------------------------------------------------------------------------------------------------------

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


InputStream.write(null, offset, len) exception throwing order differs on Harmony and RI if
offset is negative
This method throws ArrayIndexOutOfBoundsException on Harmony if byte array is null and offset
is negative, but throw NullPointerException on RI. 

Please, consider the following code: 

import java.io.IOException;
import java.io.InputStream;

public class InputStreamTest {

	public static void main(String[] args) {
		byte[] array = null;
		try {
	    	InputStream out = new InputStreamImpl();
	    	out.read(array, -1, 1);
	    } catch (NullPointerException e) {
	    	System.out.println("TEST OK: " + e);
	    } catch (Exception e) {
	    	System.out.println("TEST: NullPointerException was expected but " +
	    			e.getClass().getName() + " was thrown");
	    } 
	}
}

class InputStreamImpl extends InputStream {

	public int read() throws IOException {
		return 0;
	}
}

Output on Harmony-r553113: 

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 = r553113, (Jul  4 2007), Windows/ia32/msvc 1310, release build
http://harmony.apache.org

TEST: NullPointerException was expected but java.lang.ArrayIndexOutOfBoundsException was thrown

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)

TEST OK: java.lang.NullPointerException

Please, note that if byte array is null and length is negative NullPointerException is thrown
on Harmony as on RI


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