Details
-
Bug
-
Status: Closed
-
Trivial
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
RI throws unspecified NPE while Harmony throws specified ArrayIndexOutOfBoundsException. API specification says: "ArrayIndexOutOfBoundsException - if bankIndices or bandOffsets is null". This issue seems to be mostly RI problem. I think it is a non-bug difference from RI.
Testcase:
import junit.framework.TestCase;
import java.awt.Point;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.awt.image.RasterFormatException;
public class test extends TestCase
{
public void testcase0()
{
int[] array0 = new int[] {};
int[] array1 =null;
Point localPoint = new Point(-17796, 8);
try
catch (IllegalArgumentException expectedException)
{ fail(expectedException +" was thrown"); }catch (ArrayIndexOutOfBoundsException expectedException)
{ System.out.println(expectedException +" was thrown"); assertEquals(true,true); } }
}
OUTPUT:
Harmony+j9
.java.lang.ArrayIndexOutOfBoundsException: bankIndices or bandOffsets is null
was thrown
Time: 0.031
OK (1 test)
------------------------------------------------------------------------
Harmony+drlvm
.java.lang.ArrayIndexOutOfBoundsException: bankIndices or bandOffsets is null
was thrown
Time: 0.032
OK (1 test)
------------------------------------------------------------------------
RI
.E
Time: 0.125
There was 1 error:
1) testcase0(test)java.lang.NullPointerException
at java.awt.image.Raster.createBandedRaster(Raster.java:362)
at test.testcase0(test.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
If array1 is just empty (not null!) RI also throws ArrayIndexOutOfBoundsException while Harmony throws IllegalArgumentException , which is correct. So it's RI's behavior contradicts the spec.