algol% cat X.java
/* Adapted from Modena (v3.0) test ciner113 */
class X {
static Y oy;
static void f() { oy = new Y(); }
static class Y {
Z oz = new Z();
static class Z {
T ot =new T();
static class T {
int i = 10;
public void f() {
if (this.i!=i) System.out.println(
"err_2: i="+this.i+" Expected "+i);
}
}
}
}
static public void main(String a[]) {
try { new X().new Y().oz.ot.f(); }
catch (Exception e) { new X().new Y().oz.ot.f(); }
finally { f(); new X().oy.oz.ot.f(); }
}
}
The result of using JDK1.2.1_I javac to compile X.java is attached. The jit
was disabled, so there are line numbers in the traceback.
Altering, X.java so that the static inner class Y is not constructed with
an enclosing instance makes the problem go away. I don't see why the
construct "new X().new Y()" is even allowed. In any case, Y.java compiles
fine.
algol% cat Y.java
/* Adapted from Modena (v3.0) test ciner113 */
class X {
static Y oy;
static void f() { oy = new Y(); }
static class Y {
Z oz = new Z();
static class Z {
T ot =new T();
static class T {
int i = 10;
public void f() {
if (this.i!=i) System.out.println(
"err_2: i="+this.i+" Expected "+i);
}
}
}
}
static public void main(String a[]) {
try { new Y().oz.ot.f(); }
catch (Exception e) { new Y().oz.ot.f(); }
finally { f(); oy.oz.ot.f(); }
}
}
allan.jacobs@Eng 1999-03-29
/* Adapted from Modena (v3.0) test ciner113 */
class X {
static Y oy;
static void f() { oy = new Y(); }
static class Y {
Z oz = new Z();
static class Z {
T ot =new T();
static class T {
int i = 10;
public void f() {
if (this.i!=i) System.out.println(
"err_2: i="+this.i+" Expected "+i);
}
}
}
}
static public void main(String a[]) {
try { new X().new Y().oz.ot.f(); }
catch (Exception e) { new X().new Y().oz.ot.f(); }
finally { f(); new X().oy.oz.ot.f(); }
}
}
The result of using JDK1.2.1_I javac to compile X.java is attached. The jit
was disabled, so there are line numbers in the traceback.
Altering, X.java so that the static inner class Y is not constructed with
an enclosing instance makes the problem go away. I don't see why the
construct "new X().new Y()" is even allowed. In any case, Y.java compiles
fine.
algol% cat Y.java
/* Adapted from Modena (v3.0) test ciner113 */
class X {
static Y oy;
static void f() { oy = new Y(); }
static class Y {
Z oz = new Z();
static class Z {
T ot =new T();
static class T {
int i = 10;
public void f() {
if (this.i!=i) System.out.println(
"err_2: i="+this.i+" Expected "+i);
}
}
}
}
static public void main(String a[]) {
try { new Y().oz.ot.f(); }
catch (Exception e) { new Y().oz.ot.f(); }
finally { f(); oy.oz.ot.f(); }
}
}
allan.jacobs@Eng 1999-03-29
- duplicates
-
JDK-4150190 Qualified new of static inner class can generate incorrect code
-
- Closed
-
-
JDK-4137335 qualified new syntax is not applicable for static inner classes
-
- Closed
-