-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.2.1
-
generic, x86
-
generic, windows_nt
Variable must be a private blank final.
Variable must be used in inner class.
Error message:
% javac ES.java
ES.java:2: Blank final variable 'session' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
private final int session;
^
1 error
%
This appears to be the minimal program to reproduce:
class ES {
private final int session;
ES() {
this.session = 5;
}
class Foo {
int bar() {
return session;
}
}
}
Name: skT88420 Date: 06/23/99
class A
{
static int a = 0 ;
}
class B
{
/* must be private and refer to another class's static member or our own "class" member (i.e. B.class);
* doesn't happen if a constant is assigned to the variable;
* static doesn't matter
*/
private final int b = A.a ;
/* static doesn't matter */
class C
{
void f()
{
int c = b ;
}
}
/* javac says this variable "may not have been initialized" */
final int i ;
B(int i)
{
this.i = i ;
}
}
~$ javac Test.java
Test.java:21: Blank final variable 'i' may not have been initialized. It must be assigned a value in
an initializer, or in every constructor.
final int i ;
^
1 error
~$
This is similar to all the other blank final spurious uninitialized
bugs (e.g 4218427, 4147610)
(Review ID: 84702)
======================================================================
Variable must be used in inner class.
Error message:
% javac ES.java
ES.java:2: Blank final variable 'session' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
private final int session;
^
1 error
%
This appears to be the minimal program to reproduce:
class ES {
private final int session;
ES() {
this.session = 5;
}
class Foo {
int bar() {
return session;
}
}
}
Name: skT88420 Date: 06/23/99
class A
{
static int a = 0 ;
}
class B
{
/* must be private and refer to another class's static member or our own "class" member (i.e. B.class);
* doesn't happen if a constant is assigned to the variable;
* static doesn't matter
*/
private final int b = A.a ;
/* static doesn't matter */
class C
{
void f()
{
int c = b ;
}
}
/* javac says this variable "may not have been initialized" */
final int i ;
B(int i)
{
this.i = i ;
}
}
~$ javac Test.java
Test.java:21: Blank final variable 'i' may not have been initialized. It must be assigned a value in
an initializer, or in every constructor.
final int i ;
^
1 error
~$
This is similar to all the other blank final spurious uninitialized
bugs (e.g 4218427, 4147610)
(Review ID: 84702)
======================================================================