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

Compilation error occurs in some cases that calling extension modules that are installed via Grape.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • None
    • Groovy Version: 2.1.1 JVM: 1.7.0_17 Vendor: Oracle Corporation OS: Mac OS X

    Description

      Compilation error occurs in some cases that calling extension modules that are installed via Grape.

      In my case is "benchmark" extension of GBench:
      https://code.google.com/p/gbench/source/browse/src/main/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule

      Case 1:

      // bench.groovy
      @Grab('com.googlecode.gbench:gbench:0.4.2-groovy-2.1')
      
      benchmark {
        "do nothing" {}
      }.prettyPrint()
      

      fails with

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      bench.groovy: 3: unexpected token: benchmark @ line 3, column 1.
         benchmark {
         ^
      
      1 error
      

      Case 2:

      @Grab('com.googlecode.gbench:gbench:0.4.2-groovy-2.1')
      
      { ->
        "do nothing" {}
      }.benchmark().prettyPrint()
      

      fails with

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      3: unexpected token: { @ line 3, column 1.
         { ->
         ^
      
      1 error
      

      but it succeed when not using Grape too.

      Case 3:

      @Grab('com.googlecode.gbench:gbench:0.4.2-groovy-2.1')
      
      def c = {
        "do nothing" {}
      }
      c.benchmark().prettyPrint()
      

      fails with

      Caught: org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method benchmark() to invoke from this list:
        public static groovyx.gbench.BenchmarkList java.lang.Object#benchmark(groovy.lang.Closure)
        public static groovyx.gbench.BenchmarkList java.lang.Object#benchmark(java.util.Map, groovy.lang.Closure)
      org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method benchmark() to invoke from this list:
        public static groovyx.gbench.BenchmarkList java.lang.Object#benchmark(groovy.lang.Closure)
        public static groovyx.gbench.BenchmarkList java.lang.Object#benchmark(java.util.Map, groovy.lang.Closure)
        at bench.run(bench.groovy:6)
      

      but all the code succeed when not using Grape:

      groovy -cp gbench-0.4.2-groovy-2.1.jar bench.groovy
      

      and these code also succeed even when using Grape:

      def c = {
        "do nothing" {}
      }
      benchmark(c).prettyPrint()
      
      def r = benchmark {
        "do nothing" {}
      }
      
      r.prettyPrint()
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            nagai_masato Masato Nagai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: