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

when passing an list of gstrings to Java, it will never be treated as a String[]

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-1
    • 1.0
    • bytecode
    • None

    Description

      c = "ls";
      Runtime.getRuntime().exec(["ls"]);
      println "success"
      Runtime.getRuntime().exec(["${c}"]);
      println "success"

      This will print "success" once and then:

      Caught: groovy.lang.GroovyRuntimeException: failed to invoke method: groovy.lang.MetaClass$2@1bd0dd4[name: exec params: [class java.lang.String] returns: class java.lang.Process owner: class java.lang.Runtime] on: java.lang.Runtime@d70d7a with arguments: [[ls]]reason: java.lang.IllegalArgumentException: argument type mismatch

      We should treat GStrings universally as Strings when talking to Java ... its a tall order but this:

      Runtime.getRuntime().exec(["${c}".toString()]);

      is definitely not groovy.

      Attachments

        Issue Links

          Activity

            People

              guillaume Guillaume Sauthier
              spullara Sam Pullara
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: