Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.7, 2.3.8, 2.3.9
-
None
-
Mac OS X 10.10 with Java 8u25
Ubuntu Server 14.04.1 with Java 7u65
Description
@Grab('org.elasticsearch:elasticsearch-groovy:1.4.2') def printClosure(Closure closure) { println closure.asJsonString() } printClosure { field = "simple" }
The extension method's signature is static String asJsonString(Closure self) (https://github.com/elasticsearch/elasticsearch-groovy/blob/v1.4.2/src/main/groovy/org/elasticsearch/groovy/common/xcontent/XContentBuilderExtensions.groovy#L97).
$ groovy --indy Test.groovy Caught: groovy.lang.MissingMethodException: No signature of method: Test.asJsonString() is applicable for argument types: () values: [] Possible solutions: toString(), toString() groovy.lang.MissingMethodException: No signature of method: Test.asJsonString() is applicable for argument types: () values: [] Possible solutions: toString(), toString() at Test.printClosure(Test.groovy:3) at Test.run(Test.groovy:6)
Tested on both a Mac and Linux (with and without --indy does not matter):
- Groovy Version: 2.3.9 JVM: 1.8.0_25 Vendor: Oracle Corporation OS: Mac OS X
- Groovy Version 2.3.9 JVM: 1.7.0_65 Vendor: Oracle Corporation OS: Linux
However, if I don't use Grape/the GroovyShell, then the same code works with the same dependencies. I always use Gradle to build my code, so it wasn't until a user pointed this issue out that I became aware of it.
This relates to GROOVY-6557. On my Mac, I was always able to reproduce GROOVY-6447, but my core issue appears to relate to Closure extension methods across multiple platforms (https://github.com/elasticsearch/elasticsearch-groovy/issues/19).
Attachments
Attachments
Issue Links
- relates to
-
GROOVY-6557 Extension methods with closure parameters not found in GroovyShell
- Closed