Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-2712

[classlib][awt][compatibility] java.awt.image.Raster.createBandedRaster(int,int,int,int,int[],int[],Point) throws ArrayIndexOutOfBoundsException while Ri throws NPE

    XMLWordPrintableJSON

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

      { Raster.createBandedRaster(9,65412,5,-1,array0,array1,localPoint); assertEquals(true, false); }

      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.

      Attachments

        Activity

          People

            zakha Alexei Zakharov
            oleg.v.khaschansky@gmail.com Oleg Khaschansky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: