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

Confusing compilation errors for local "static final blah..."

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.1, 1.1.5
    • tools
    • None
    • sparc
    • solaris_2.5.1



      Name: tb29552 Date: 07/30/97


      Reported by: company - University College London (Computer Science Dept.)
                          email - ###@###.###

      When adding a local variable to a method, I accidentaly declaired
      it as static and final. Rather than report this as wrong, the
      compiler kind of 'fell over'. eg:

      ==== ABug.java ===========================
      {
          bar()
          {
              // confusion...
       
              static final int barfoo = 0;
              if (true)
              {
                  // do something
              }
          }
      }
      ==========================================

      produces the following compiler errors:


      ABug.java:6: '}' expected.
              {
               ^
      ABug.java:9: Statement expected.
                      static final int barfoo = 0;
                      ^
      ABug.java:10: Type expected.
                      if (true)
                      ^
      3 errors

      ... since I had made edits in a few surrounding methods as well,
      this took me a while to track down.

      company - University College London (Computer Science Dept.) , email - ###@###.###
      ======================================================================

            iris Iris Clark
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: