-
Bug
-
Resolution: Fixed
-
P3
-
1.0.2, 1.1
-
1.1fcs
-
sparc
-
solaris_2.5
-
Not verified
Name: laC46010 Date: 10/28/96
The Java Language Specification says:
[8.3.2.2 Initializers for Instance Variables, p.150]
"Initialization expressions for instance variables are
permitted to refer to the current object this (15.7.2) and to
use the keyword super (15.10.2, 15.11)."
[15.10.2 Accessing Superclass Members using super, p.322]
"The special form using the keyword super is valid only in an
instance method or constructor, or in the initializer of an
instance variable of a class; these are exactly the same
situations in which the keyword this may be used (15.7.2)."
However compiler (both 1.0.2 and 1.1) treats "super" as undefined variable
in an instance variable initializer and reports an error:
> /export/ld32/jdk_1.0.2/bin/javac clss10203.java
clss10203.java:10: Undefined variable: super
int k = super.j;
^
1 error
> /export/ld32/jdk_1.1/bin/javac clss10203.java
clss10203.java:10: Undefined variable: super
int k = super.j;
^
clss10203.java:10: Undefined variable: super
int k = super.j;
^
2 errors
Besides 1.1 version reports the message twice
but it's probably defect of the September version.
------------------clss10203.java---------------------
class clss10203_a {
int j = 1;
}
public class clss10203 extends clss10203_a {
void f() {
int n = super.j;
super.j = 1;
}
int k = super.j;
}
-----------------------------------------------------
======================================================================