Exception transparency
Peter Levart
peter.levart at marand.si
Tue Jun 8 04:54:47 PDT 2010
On 06/08/10, Maurizio Cimadamore wrote:
> >> needs to guess any intentions where it will affect realistic code.
> >>
> >>
> > Neal,
> > I have trouble to figure out an example of such rare places.
> >
> > Do you have an example of such code ?
> >
> Could be this?
>
> class A<X> extends Exception {}
> class B extends A<String> {}
> class C extends A<Integer> {}
>
> <throws E> E choose(E e1, E e2) { ... }
>
> choose(new B(), new C()); //what is the inferred type for E???
>
> In JDK 5/6 E is inferred to be A<? extends Object & Comparable<? extends
> Object & Comparable<?>>>. In JDK 7 with the proposed new semantics for
> 'exception-bound' type-vars the inferred type would be something like
> A<String> | A<Integer>, which, I guess, would need to be rejected as an
> ill-formed type on the grounds of type-disjointness (A<String> and
> A<Integer> are not provably distinct).
Are you suggesting to relax the rule that generic classes can not extend Throwable?
Peter
>
> Maurizio
>
More information about the lambda-dev
mailing list