Name: igT44549 Date: 02/08/99
Given the following code:
class Test
{
final int x ;
Test()
{
try
{
x = f() ;
}
catch(Exception e)
{
x = 0 ;
}
System.err.println("x=" + x) ;
}
int f() throws Exception
{
return 1 ;
}
}
javac from the jdk1.1.7 compiles this code successfully.
javac from the jdk1.2ea results in the following errors:
Test.java:3: Blank final variable 'x' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
final int x ;
^
Test.java:12: Can't assign a second value to a blank final variable: x
x = 0 ;
^
Test.java:14: Variable x may not have been initialized.
System.err.println("x=" + x) ;
^
3 errors
(Review ID: 49071)
======================================================================