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

Groovy2 indy not backward compatible missingMethod with Groovy3

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.8, 4.0.0-alpha-3
    • Compiler
    • None

    Description

      I am getting a

      Exception in thread "main" java.lang.IllegalArgumentException: array is not of length 1

      To reproduce, compile the following in Groovy 2.5 with

      groovyOptions.optimizationOptions.indy = true

       

      package first
      
      class Library {   
          def foo(a, b= '<1>', c= '<2>') {
              "$a" + b + c     
          }      
          def methodMissing(String name, args) {        
              foo(name, *args[1..<args.size()])     
          } 
      }

      Then reference the code in Groovy 3.0.5 to reproduce the error

      package second 
      import first.Library 
      class App { 
          static void main(String[] args) { 
              println new Library().bar( 'a' )        
              println new Library().bin( 'a''b')     
          } 
      }

       
      Note that if both are compiled with Groovy2 or Groovy3 the error does not occur.

      This is probably similar to https://issues.apache.org/jira/browse/GROOVY-9515?jql=text%20~%20%22%5C%22array%20is%20not%20of%20length%201%5C%22%22

      Attachments

        Activity

          People

            emilles Eric Milles
            aibolit Aleks Tamarkin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 40m
                1h 40m