Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6446

Groovy-module's extension method don't work by Grape Annotation(sometimes)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.0
    • 2.3.5
    • Grape
    • None
    • java version "1.7.0_10"
      Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

      MacOSX 10.9 Marverics

    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

        1. test.zip
          107 kB
          UEHARA Junji

        Issue Links

          Activity

            People

              paulk Paul King
              uehaj UEHARA Junji
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: