-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
25
With Flexible Constructor Bodies, it becomes possible for an explicit constructor invocation to be unreachable. The current rule in 14.22 does not apply to constructor invocations, because they are not *statements*:
"It is a compile-time error if a statement cannot be executed because it is unreachable."
Besides stating the error condition, I think the section will need to add some rules about when an explicit constructor invocation is reachable.
javac properly enforces the rule, rejecting an unreachable explicit constructor invocation:
class C {
C() {
throw new RuntimeException();
super();
}
}
| Error:
| unreachable statement
| super();
| ^------^
"It is a compile-time error if a statement cannot be executed because it is unreachable."
Besides stating the error condition, I think the section will need to add some rules about when an explicit constructor invocation is reachable.
javac properly enforces the rule, rejecting an unreachable explicit constructor invocation:
class C {
C() {
throw new RuntimeException();
super();
}
}
| Error:
| unreachable statement
| super();
| ^------^