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

vague error generated for field modifiers in local context

XMLWordPrintable

    • sparc
    • generic, solaris_2.5.1


      According to the language spec, 8.3.1 static and final are one of 7 field modifiers which only
      modify class fields (Not local variables). This makes sense, but has the potiental to trip up C programmers
      (and does - i have fp.bugs to prove it). A better error message could save a lot of hours of debugging.

      see the following code:

      import java.lang.*;
      public class t {
        public void main(String args[]) {
           final <add any field modifier here> int j;
           System.out.println(j);
        }
      }


      t.java:3: Missing term.
        public void main(String args[]) {
                                         ^
      t.java:3: ';' expected.
        public void main(String args[]) {
                                         ^
      t.java:4: Invalid expression statement.
        final int j;
        ^
      3 errors


            wmaddoxsunw William Maddox (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: