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

Suboptimal expression in javax.imageio.ImageTypeSpecifier.getBitsPerBand(int)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 6, 9
    • client-libs
    • b114
    • generic
    • generic

      The code uses non-short-circuit logic (|) rather than short-circuit logic (||). Non-short-circuit logic causes both sides of the expression to be evaluated even when the result can be inferred from knowing the left-hand side.

      $ pwd
      /local-copy/1.6.0-rc-b69_src/j2se/src/share/classes/javax/imageio
      $ tail +1095 ImageTypeSpecifier.java | head -6
          public int getBitsPerBand(int band) {
              if (band < 0 | band >= getNumBands()) { // <<------- here
                  throw new IllegalArgumentException("band out of range!");
              }
              return sampleModel.getSampleSize(band);
          }

            psadhukhan Prasanta Sadhukhan
            jloefflm Johann Löfflmann (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: