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

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

    XMLWordPrintable

Details

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

    Description

      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);
          }

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: