Details
Description
Sometimes Groovy module's extension methods don't inject to target Class when get the module by Grab annotation.
I attached test code but easy way to regenerate this issue is, use tim yates's groovy-stream:
@Grab( 'com.bloidonia:groovy-stream:0.6.2' ) import groovy.stream.Stream println([1,2,3].iterator().toStream())
fails indeterminately in my environment(1 time per 3 .. 10 trial, or serial)
Caught: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList$Itr.toStream() is applicable for argument types: () values: []
Possible solutions: toString(), toString(), toSet()
groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList$Itr.toStream() is applicable for argument types: () values: []
Possible solutions: toString(), toString(), toSet()
at s.run(s.groovy:5)
Following code seems to success.
groovy.grape.Grape.grab(['group': 'com.bloidonia', 'module': 'groovy-stream', 'version': '0.6.2']) println([1,2,3].iterator().toStream())
Is it related to static class initializer invocation timing? I don't sure.
Attached code trying to generate this problem in test case, but it don't work
under testing framework by some reason I can't tell.
So to regenerate it you have to use groovy command from shell:
% unzip test.zip
% cd test
% ./gradlew uploadArchives # put module into /tmp/myRepo
% groovy src/test/resouces/GrabTest.groovy
Caught: groovy.lang.MissingMethodException: No signature of method: java.lang.String.hello() is applicable for argument types: () values: []
Possible solutions: sleep(long), sleep(long, groovy.lang.Closure), split(), next(), split(), next()
groovy.lang.MissingMethodException: No signature of method: java.lang.String.hello() is applicable for argument types: () values: []
Possible solutions: sleep(long), sleep(long, groovy.lang.Closure), split(), next(), split(), next()
at sample.GrabTest.main(GrabTest.groovy:10)
P.S. If you put the groovy-module jar in your class path, it succeed.
Attachments
Attachments
Issue Links
- relates to
-
GROOVY-6447 Groovy-module's extension method don't work by Grape Annotation(always on Java SE 8)
- Closed