The diagnostic for the following ill-formed program is potentially confusing, since the diagnostic only mentions that the fields is final (not that it is static), and initializing non-static final fields in the constructor is legal.
Something like the following might be make the error easier to understand:
> cannot assign a value to static final field g; did you mean to initialize it in a static initializer block or static field initializer?
```
public class T {
private static final boolean g;
T(boolean g) {
this.g = g;
}
}
```
$ javac T.java
T.java:4: error: cannot assign a value to final variable g
this.g = g;
^
1 error
Something like the following might be make the error easier to understand:
> cannot assign a value to static final field g; did you mean to initialize it in a static initializer block or static field initializer?
```
public class T {
private static final boolean g;
T(boolean g) {
this.g = g;
}
}
```
$ javac T.java
T.java:4: error: cannot assign a value to final variable g
this.g = g;
^
1 error