Lambda conversion in Method invocation context
Arul Dhesiaseelan
aruld at acm.org
Thu Nov 11 20:21:17 PST 2010
Hi,
I get the following compile error when I use a lambda in a method invocation
context:
SimpleRunnable.java:14: internal error; cannot instantiate println(String)
at ExecutorService to (<>#void())
executor.submit(#{System.out.println("Processing a
short-lived asynchronous task.")});
^
1 error
final ExecutorService executor = Executors.newCachedThreadPool();
Runnable task = #{ System.out.println("Processing a short-lived asynchronous
task.") };//compiles
executor.submit(task);
task = (Runnable)#{System.out.println("Processing a short-lived asynchronous
task.")};//compiles
executor.submit(task);
executor.submit(#{System.out.println("Processing a short-lived asynchronous
task.")});//fails
I am not sure if this is supported in the compiler yet. Just thought of
checking on the mailing list.
-Arul
More information about the lambda-dev
mailing list