The philosophy of Nothing
Per Bothner
per at bothner.com
Sun Nov 29 18:34:42 PST 2009
On 11/29/2009 06:14 PM, Paul Benedict wrote:
1) Does the Java compiler have to prove a method can never return normally?
It should be (and can easily be) integrated with unreachable-code
analysis.
> 2) What is the benefit of telling the compiler the method *must* throw
> an Exception?
The useful case, I believe, is specifying that a method never
returns "normally" - i.e. it either throws an exception *or*
loops forever. Thus any code following a call to such a
method is by definition unreachable.
public Nothing throwMe(RuntimeException t) {
throw t;
}
public void doit() {
throwMe(...);
// unreachable here
do_something(); // hence this is an error
}
--
--Per Bothner
per at bothner.com http://per.bothner.com/
More information about the coin-dev
mailing list