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

Null argument to methods with vararg parameters are replaced with array of length 1

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.0-JSR-4
    • 1.0-JSR-4
    • None
    • None

    Description

      This code now fails:

      package groovy.bugs;
      import java.lang.reflect.*
      class ReflectionInvokeBug extends GroovyTestCase {
      void testInvoke()

      { def clazz = "org.codehaus.groovy.dummy.ClassWithStaticMethod" Class c = Class.forName(clazz) Method init = c.getDeclaredMethod("staticMethod", null) }

      }

      with this exception:

      [java] There was 1 error:
      [java] 1) testInvoke(groovy.bugs.ReflectionInvokeBug)java.lang.ClassCastException: [Ljava.lang.Object;
      [java] at gjdk.java.lang.Class_GroovyReflector.invoke(Unknown Source)
      [java] at groovy.lang.MetaMethod.invoke(MetaMethod.java:110)
      [java] at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:1557)
      [java] at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:520)
      [java] at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:137)
      [java] at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:104)
      [java] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethod(ScriptBytecodeAdapter.java:85)
      [java] at groovy.bugs.ReflectionInvokeBug.testInvoke(Unknown Source)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [java] at groovy.util.GroovyTestSuite.main(GroovyTestSuite.java:79)
      [java]

      This must be due to some recent change since I upgraded today and it worked before.

      Attachments

        1. NullArgumentBug.groovy
          0.9 kB
          Hein Meling
        2. ReflectionInvokeBug.groovy
          0.4 kB
          Hein Meling

        Issue Links

          Activity

            People

              phkim Kim, Pilho
              meling Hein Meling
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: