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

Compiler does not warn about unused variables.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.2.0
    • tools
    • None
    • sparc
    • solaris_2.5.1



      Name: sg39081 Date: 10/28/97


      Look at the method java.lang.String.toCharArray():
          public char[] toCharArray() {
              int i, max = length();
              char result[] = new char[max];
              getChars(0, max, result, 0);
              return result;
          }
      See the variable 'i'? Its extraneous (and ought to have a
      bug entered concerning that fact...), but the bigger issue
      is that there is no warning level flag on the compiler, javac, that
      would tell the engineer that the code is
      extraneous - this is a bug. For example,
      Gcc issues warnings like "variable i set but never used".
      Now, any compiler worth its salt will not generate any
      code for the variable 'i', but still, a warning flag
      would be good.
      (Review ID: 19408)
      ======================================================================

            dstoutamsunw David Stoutamire (Inactive)
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: