On Friday, March 25, 2011 11:14:18 AM UTC+1, mP wrote:
>
> Perhaps just perhaps the problem is that heirarchy is both a grouping 
> mechanism and a way to define checkness. Therefore if a marker was applied 
> to an exception to denote whether it (the exception) was checked or 
> unchecked ignoring whether it extended exception/runtime etc perhaps things 
> would be better and more flexible.More hyperbole perhaps including a Checked 
> and Unchecked marker interfaces do the trick. The way to solve a child 
> implementing Unchecked if a parent was Checked would be that the compiler 
> would respect the most derived implements. Since Annotations were not around 
> its perhaps the best solution for this mess.
>
>    Parent implements Checked // compiler treats Parent as checked.
>     Child implemented Unchecked // compiler treats Child as unchecked
>

This would not work all that well without abandoning the ability for 
exceptions to be grouped based on type, which is also useful. If for example 
IOEx was unchecked, but FNFEx was checked, and RemoteEx was unchecked (which 
is what you propose), then declaring that you "throw IOException" is not 
sufficient to force callers to acknowledge the FNFEx, assuming you throw it. 
So what happens when I try this stunt:

IOException ex = new FileNotFoundException(...);
throw ex;

How'd the compiler figure this out? It would have to enforce a new standard 
for exceptions and basically disable or severely curtail their object-ness, 
for example by requiring all throw statements to be of the form "throw new 
Something();" and not just "throw someVar;". This is a problem too, because 
exceptions are also used as data objects that can be introspected to learn 
more about what went wrong.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to