Name: igT44549 Date: 02/10/99
/*
javac compiles the following illegal program:
(The two Y constructors are mutually recursive.)
*/
package test;
public class X {
public static void main(final String[] args) {
new X ().new Y();
}
class Y {
Y () {
X.this.this(X.this);
}
Y (X x) {
x.this();
}
}
}
(Review ID: 53621)
======================================================================
It is hardly necessary to use such a complex example, e.g., using
the qualified 'this()' notation. The following case also exhibits
the bug:
class Y {
Y () {
this(1);
}
Y (int x) {
this();
}
}
william.maddox@Eng 1999-02-12
- duplicates
-
JDK-4312812 javac allows to constructor invoke itself through invocations involving 'this'
- Closed
-
JDK-1229458 compiler does not spot mutually recursive constructors
- Closed