P
Paul Chapman
I've just updraded to jdk1.5.0_01. I've already found that generics improve
my code.
I've just been rewriting some base-class methods which should never be
called. Previously they might look like:
protected int method()
{
throw new RuntimException();
}
The compiler doesn't complain that there's no return statement, presumably
because it knows that the throw means the method will never return normally.
I am rewriting these to use assert, thus:
protected int method()
{
assert false;
}
This seems to me to be a reasonable thing to do, and an improvement. The
new compiler complains that there is no return statement. I think it might
be improved to recognize that the assertion will always throw an exception.
Any views?
Cheers, Paul
my code.
I've just been rewriting some base-class methods which should never be
called. Previously they might look like:
protected int method()
{
throw new RuntimException();
}
The compiler doesn't complain that there's no return statement, presumably
because it knows that the throw means the method will never return normally.
I am rewriting these to use assert, thus:
protected int method()
{
assert false;
}
This seems to me to be a reasonable thing to do, and an improvement. The
new compiler complains that there is no return statement. I think it might
be improved to recognize that the assertion will always throw an exception.
Any views?
Cheers, Paul