Name: avC70361 Date: 02/11/99
javac of jdk 1.2.2 doesn't correctly compile a class which contains a final private field
and an inner non-static class. The field is initialized in the class constructor and the inner
class code should reference to the field. In that case the javac throws an error: "Blank final
variable 'a' may not have been initialized. It must be assigned a value in an initializer, or
in every constructor". But the field has been initialized in the constructor.
If the field is not private, or is not refferenced to in the inner class, or initialized by
not a constructor code the bug doesn't arises.
Here is a test demonstrating the bug.
---------------A.java--------------
public class A {
final private Object a;
public A() {
a = null;
}
public class B {
Object b;
public B() {
b = a;
}
}
}
--------------The test output---------
> javac A.java
A.java:2: Blank final variable 'a' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
final private Object a;
^
1 error
======================================================================