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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6, 9
    • Fix Version/s: 9
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b114
    • CPU:
      generic
    • OS:
      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

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: