Delete me.
On Mon, 16 Jul 2018 at 08:33, Paolo Di Tommaso <[email protected]>
wrote:
> Dear all,
>
> I'mv trying to use the new `macro` feature to execute a class method call
> expression using an executor service.
>
> I've tried:
>
>
> private BlockStatement wrap(MethodCallExpression mce) {
> return macro(true,{
>
> def executor =
> java.util.concurrent.Executors.newCachedThreadPool()
> def list = new ArrayList(1)
> list.add( { return $v{ mce } } as Callable )
> def result = executor.invokeAll(list)
> return result.get(0).get()
>
> })
> }
>
>
> and
>
>
> private BlockStatement wrap(MethodCallExpression mce) {
> return macro(true,{
>
> def task = new java.util.concurrent.Callable<Object>() {
> @Override
> Object call() throws Exception { return $v{ mce } }
> }
>
> ExecutorService executor =
> java.util.concurrent.Executors.newCachedThreadPool()
> def list = new ArrayList(1)
> list.add(task)
> def result = executor.invokeAll(list)
> return result.get(0).get()
>
> })
> }
>
>
> However none of them work. The first return a NPE during compilation and
> the second reports:
>
> Groovyc: [Static type checking] - Cannot find matching method
> nextflow.ast.ProxyImpl$1#$v(groovy.lang.Closure). Please check if the
> declared type is correct and if the method exists.
>
> (using CompileDynamic I got a NPE error one more time)
>
>
> What I'm missing? is it possible to handle this use case with an ast macro
> ?
>
>
>
> p
>
>