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

Impossible null check in Raster#createBandedRaster

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5 P5
    • tbd
    • 20
    • client-libs
    • None
    • 2d

      There is a null check of parameter 'bandOffsets' in the method 'java.awt.image.Raster#createBandedRaster(int, int, int, int, int[], int[], java.awt.Point)'
      https://github.com/openjdk/jdk/blob/ab06a878f888827026424530781f0af414a8a611/src/java.desktop/share/classes/java/awt/image/Raster.java#L441

      But just a few lines above there is a statement which dereferences this 'bandOffset'

              int bands = bandOffsets.length;
              ...
              if (bandOffsets == null) {
                  throw new
                      ArrayIndexOutOfBoundsException("Band offsets array is null");
              }

      It means we can safely remove this 'if'. NPE will be throw by JVM if parameter is null.

            prr Philip Race
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: