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
- duplicates
-
JDK-4068503 Confusing compilation errors for local "static final blah..."
- Closed