Re: compiler warning
- From: Dale King <DaleWKing@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 17 Aug 2005 12:50:42 GMT
Thomas G. Marshall wrote:
Patricia Shanahan coughed up:
And I'm not convinced that it is a particularly useful restriction worthy of any hissy fit ;) from the compiler engineers at sun. Save for a minor slap in the face to the structured programming zealots (which I condone anyway), I just don't see the problem.
Then I don't think you are looking hard enough.
Take this method:
public int foo() throws Exception
{
try
{
bar();
return 1;
}
catch( IOException e )
{
return 2;
}
finally
{
return 3;
}
}Quick, without thinking too hard about it, what happens in these cases:
- bar completes normally - bar throws an IOException - bar throws an exception other IOException
While you a seasoned veteran probably can figure out the answers don't you think the fact that it returns 3 in all cases might be confusing to a newbie?
If there were a valid use case for having a return statement in a finally block then there might be a reason to not have the warning.
Since there isn't a good use case for it and the behavior will be confusing to newbies and possibly cause undesirable behavior then it is a good idea to warn people.
-- Dale King .
- References:
- compiler warning
- From: dennishancy
- Re: compiler warning
- From: Chris Smith
- Re: compiler warning
- From: Harry Bosch
- Re: compiler warning
- From: Patricia Shanahan
- compiler warning
- Prev by Date: Re: coding trick to reduce number of small objects generated
- Next by Date: Re: Interface freeloading on a superclass - is it good practice?
- Previous by thread: Re: compiler warning
- Next by thread: Re: compiler warning
- Index(es):
Relevant Pages
|
|