error: 'throws' type-parameter not allowed here
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Jun 23 01:22:39 PDT 2011
On 23/06/11 06:42, Ali Ebrahimi wrote:
> Hi,
>
> for line 2, i get this error: 'throws' type-parameter not allowed here
>
> public interface MList<T> extends List<T> {
> <throws E> void forEach(ExBlock<T,E> method) throws E default
> Trait.<T,E>forEach;
>
> static class Trait {
> public static<T,throws E>
> void forEach(
> final MList<T> self, final ExBlock<T,E> method) throws E{
> for (int i = 0; i< self.size(); i++) {
> method.call(self.get(i));
> }
> }
> }
> }
>
> public interface ExBlock<A1,throws E>{
> void call(A1 a1) throws E;
> }
>
>
> Is this expected behavior or ...?
Hi Ali,
it seems like throws type parameter are rejected in method calls:
class A {
<throws E> void m() {}
<throws E1> void test() {
this.<E1>m(); //error - throws type-parameter not expected here
}
}
This is not deliberate: you are supposed to pass a throws type-argument
where the corresponding formal in the called method is another throws
type-parameter.
Thanks for the headsup
Maurizio
> Ali Ebrahimi
>
More information about the lambda-dev
mailing list