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

Can not pass String[] to constructor

    XMLWordPrintableJSON

Details

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

    Description

      Another array/constructor problem...

      The following, looks like it should create a new Runner instance with String[]...

      <snip>
      class Runner implements Runnable
      {
      String[] args

      Runner(String[] args)

      { this.args = args }

      void run()

      { println("hi") }

      }

      String[] args = new String[]

      { "a", "b" }

      println(args)
      println(args.class)
      runner = new Runner(args)
      </snip>

      Running with groovy outputs:

      <snip>
      [Ljava.lang.String;@7eb767
      class [Ljava.lang.String;
      Caught: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: Runner(java.lang.String, java.lang.String)
      groovy.lang.GroovyRuntimeException: Could not find matching constructor for: Runner(java.lang.String, java.lang.String)
      at groovy.lang.MetaClass.invokeConstructor(MetaClass.java:437)
      at org.codehaus.groovy.runtime.Invoker.invokeConstructorOf(Invoker.java:168)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:133)
      at Test.run(Test.groovy:16)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:63)
      at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:1032)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:314)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:291)
      at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:73)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:126)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:106)
      at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:374)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      ...
      </snip>

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: