Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
2.1.1
-
None
-
using Gpars 1.0 and groovy 2.1.1
Description
When attempting to use both @CompileStatic and GPars (either GParsPool or GParsExecutorPool) there is a compile time error.
The following sample code:
Example test case showing a few examples that should work
import groovy.transform.CompileStatic import groovyx.gpars.GParsExecutorsPool import java.util.concurrent.ForkJoinPool @CompileStatic class GParsStatic { def foo = ["foo", "bar", "blarg", "doo", "woop", "bliz"] ForkJoinPool forkJoinPool = new ForkJoinPool() void testEachParallel() { GParsExecutorsPool.withExistingPool(forkJoinPool) { foo.eachParallel { String entry -> println("${entry}") } } } void testEachWithIndexParallel() { GParsExecutorsPool.withExistingPool(forkJoinPool) { foo.eachWithIndexParallel { String entry, int i -> println("${entry} at index ${i}") } } } }
produces the errors:
Groovyc: [Static type checking] - Cannot find matching method java.lang.Object#eachParallel(groovy.lang.Closure). Please check if the declared type is right and if the method exists. Groovyc: [Static type checking] - Cannot find matching method java.lang.Object#eachWithIndexParallel(groovy.lang.Closure). Please check if the declared type is right and if the method exists.
Since this is a compile-time error, I haven't created a junit test for it (I do have a simple spock test, if it helps
"simple spock test that calls the methods that should work"
import spock.lang.Specification class GParsStaticSpec extends Specification{ def "test that method runs"() { setup: GparsStaticCompile gparsStaticCompile = new GparsStaticCompile() when: gparsStaticCompile.testEachWithIndexParallel() gparsStaticCompile.testEachParallel() then: notThrown(Exception) } }
If the
{monospaced}@CompileStatic{monospaced}is removed, the class compiles and the methods run properly.