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

Invoker.asArray, does not function w/ Constructors with (String[]) params

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-beta-6
    • 1.0-JSR-2
    • None
    • None

    Description

      Invoker.asArray() does not do the right thing when converting input args into compatible args for Constructor.newInstance().

      Specifically, when calling a constructor with one argument of type String[], asArray() does not wrap the input arguments in a new Object[], which results in passing the input String[] to the constructor, which then throws an IllegalArumentException, as it expected something like: new Object[]

      { stringArray }

      My guess is that this problem occurs for all constructors which take a single argument, whoes value passes an instanceof Object[] test.

      I tested that hacking up Invoker.asArray with:

      if (arguments instanceof String[]) {
      return new Object[]

      { arguments }

      ;
      }

      did the right thing.

      --jason

      Attachments

        1. ConstructorArgumentsTest.groovy
          0.7 kB
          Jason Dillon
        2. AsmClassGenerator.patch
          0.7 kB
          Jason Dillon

        Activity

          People

            blackdrag Jochen Theodorou
            jason@planet57.com Jason Dillon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: