Impossible null check in Raster#createBandedRaster

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P5
    • tbd
    • Affects Version/s: 20
    • Component/s: 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.

            Assignee:
            Philip Race
            Reporter:
            Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: