-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.6, 1.2.0, 1.2.1
-
x86, sparc
-
solaris_2.6, windows_95, windows_nt
Name: tb29552 Date: 06/18/98
/*
* The output from the following code should be "enclosing
* x is 10 \n y is 9". The code works if using the
* tradition class initialization method, but fails if
* using short-handed static inner class initialization
* method. The output from the latter approach is
* "enclosing x is 10 \n y is 0". The initialization
* fails.
*
* The same problem is found in Symantec JIT compiler
* version "JIT 210.054 JD 1.1.2" and "HP-UX Java
* B.01.13.04".
*/
public class OuterOne {
static int x=10;
static public class InnerOne {
int y=9;
public void innerMethod() {
System.out.println("enclosing x is " + x);
System.out.println("y is " + y);
}
}
public void outerMethod() {
System.out.println("x is " + x);
}
public static void main(String args[]) {
// short-hand inner class initialization method
OuterOne.InnerOne i1 = new OuterOne().new InnerOne();
i1.innerMethod();
// traditional method
OuterOne o = new OuterOne();
InnerOne i2 = o.new InnerOne();
i2.innerMethod();
}
}
(Review ID: 30802)
======================================================================
- duplicates
-
JDK-4200682 Static inner class does not get instantiated correctly
-
- Closed
-
-
JDK-4226468 new Y().new Z() where Z is a static, inner class gets VerifyError.
-
- Closed
-
-
JDK-4225105 Odd inner class code construct causes the compiler to abort.
-
- Closed
-