Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8255800

Raster creation methods need some specification clean up

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      b17

      Description

      As per Java spec
      ArrayIndexOutOfBoundsException - if bankIndices or bandOffsets is null.

      If we provide bandOffsets as null, existing JDK implementation is throwing NullPointerException which is not as per spec. It should throw ArrayIndexOutOfBoundsException.

      A sample demonstrating the problem:
       public static void main(String[] args) {
              try {
                  WritableRaster writableRaster = Raster.createBandedRaster(
                          DataBuffer.TYPE_INT, 5, 1, 3, new int[]{0, 0}, null, new Point());
              } catch (Throwable t) {
                  System.out.println(t);
              }
          }

      Output:
      java.lang.NullPointerException: Cannot read the array length because "bandOffsets" is null.

      Code snippet causing issue:
             
              int bands = bandOffsets.length;

              if (bankIndices == null) {
                  throw new
                      ArrayIndexOutOfBoundsException("Bank indices array is null");
              }
              if (bandOffsets == null) {
                  throw new
                      ArrayIndexOutOfBoundsException("Band offsets array is null");
              }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              prr Philip Race
              Reporter:
              amadgundi Asha Madgundi
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: