-
Bug
-
Resolution: Duplicate
-
P5
-
None
-
1.1.2
-
sparc
-
solaris_2.5.1
If a class has two constructors that each call the other with this(...),
this could be called an warning, because it is never possible for this to
not throw an exception. (It will end with StackOverflowError, OutOfMemoryError, or if the argument evaluations throw any exception).
While it may be reasonable to allow this for the side effects the argument evaluations could have, I believe a warning would make much more sense than
saying nothing.
Example code:
public class ConCir {
public ConCir(int a, double d){
this(a,d,0);
}
public ConCir(int a, double d, int b){
this(a,d);
}
public static void main(String[] args){
new ConCir(0,0.0);
}
}
this could be called an warning, because it is never possible for this to
not throw an exception. (It will end with StackOverflowError, OutOfMemoryError, or if the argument evaluations throw any exception).
While it may be reasonable to allow this for the side effects the argument evaluations could have, I believe a warning would make much more sense than
saying nothing.
Example code:
public class ConCir {
public ConCir(int a, double d){
this(a,d,0);
}
public ConCir(int a, double d, int b){
this(a,d);
}
public static void main(String[] args){
new ConCir(0,0.0);
}
}
- duplicates
-
JDK-1229458 compiler does not spot mutually recursive constructors
- Closed