-
Bug
-
Resolution: Fixed
-
P5
-
1.2.0
-
1.2fcs
-
sparc
-
solaris_2.5.1
-
Not verified
Name: tb29552 Date: 04/29/98
the following program prints
Error at err3 :: Z.this.m = 1 :: expected value 100
According to the inner class documentation, the
qualified this syntax should cause references to
enclosing instances. (Anyway, why have another
way to refer to the super instance?)
//Chk.java:
class Chk {
Chk(){}
public static boolean ErrorFlag = false;
public static boolean chkIntVal(String errStr, String varName, int val, int expectedVal)
{
if(val!=expectedVal) {
ErrorFlag=true;
System.out.println("Error at " + errStr + " :: " + varName + " = " + val +" :: expected value " + expectedVal);
return false;
}
else
return true;
}
}
//X.java:
class X
{
int m=101;
class Z
{
int m=100;
void test()
{
new Z()
{
int m=200;
void test()
{
Chk.chkIntVal("err1","m",m,200);
super.m = 1;
Chk.chkIntVal("err2","super.m",super.m,1);
Chk.chkIntVal("err3","Z.this.m",Z.this.m,100);
Chk.chkIntVal("err4","X.this.m",X.this.m,101);
}
}.test();
}
}
void xtest()
{
new Z().test() ;
}
public static void main(String[] s)
{
new X().xtest();
}
}
(Review ID: 29251)
======================================================================
- relates to
-
JDK-4185503 Cannot access anonymous enclosing class of anonymous class
- Closed
-
JDK-4196407 compiler does not initialize a field of an anonymous inner class
- Closed