Question on exception transparency
Rizal Anwar
anrizal05 at yahoo.fr
Mon Aug 9 23:16:28 PDT 2010
Hi,
I played around with the prototype, and I have a question on exception
transparency, especially in type inference.
I have the following interface:
public interface Block<T, throws E> {
void run(T param) throws E;
}
and the following code (assuming ListUtil.foreach is a method accepting a list
and a Block).
public static void main(String args[]) {
List<String> myList = Arrays.<String>asList("A", "B", "K");
try {
ListUtil.foreach(
myList,
Block<String, BlockExecutionException> #(x) {execute(x)});
////////////////////////////////////////////////////////////
}
catch (BlockExecutionException e) {
e.printStackTrace();
}
}
private static void execute(String x) throws BlockExecutionException {
System.out.println("Execute" + x);
}
}
I wonder whether there is a way not to specify the target Block<String,
BlockExecutionException> in the closure I use in the above code ?
Isn't is possible to infer the type ?
Best regards,
Anwar Rizal.
More information about the lambda-dev
mailing list