Groovy
  1. Groovy
  2. GROOVY-543

Incorrect exception MissingMethodException when closure references an uninitialized variable

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-beta-5
    • Fix Version/s: 1.0-JSR-1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Intel based Linux, java version "1.4.1_05"

      Description

      The enclosed simple program demostrates the problem:
      #!/usr/bin/env groov

      def process( root, group, item ) {
      g = [root, group, item];
      g.sort

      { a, b | b < c }

      }

      if (args.size() < 3) {
      println "3 args please";
      } else {
      args[2..args.size()-1].each

      { process(args[0], args[1], it) }

      }

      When run with more than 3 arguments, this traceback is reported when the actual error is the reference to the uninitialized variable "c" in the sort closure.

      102 9:37am mhusby@gallium ~/groovy > ./junk.groovy 9 2 3
      Caught: groovy.lang.MissingMethodException: No signature of method junk$1.process() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.String) values: [9, 2, 3]
      groovy.lang.MissingMethodException: No signature of method junk$1.process() is applicable for argument types: (java.lang.String, java.lang.String, java.lang.String) values: [9, 2, 3]
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:317)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:291)
      at groovy.lang.Closure.doInvokeMethod(Closure.java:90)
      at groovy.lang.Closure.invokeMethod(Closure.java:75)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:126)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:106)
      at junk$1.doCall(junk.groovy)
      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.Closure.call(Closure.java:208)
      at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:304)
      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 org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:99)
      at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:1020)
      at groovy.lang.MetaClass.invokeMethod(MetaClass.java:314)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:139)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:106)
      at junk.run(junk.groovy:12)
      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:1020)
      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)
      at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:63)
      at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:1020)
      at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:375)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:133)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:106)
      at junk.main(junk.groovy)
      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:1020)
      at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:375)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:133)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:106)
      at groovy.lang.GroovyShell.run(GroovyShell.java:222)
      at groovy.lang.GroovyShell.main(GroovyShell.java:92)
      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.classworlds.Launcher.launchStandard(Launcher.java:410)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:344)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:474)

        Activity

        Erik Husby created issue -
        Jochen Theodorou made changes -
        Field Original Value New Value
        Assignee Jochen Theodorou [ blackdrag ]
        Hide
        Jochen Theodorou added a comment -

        fixed due to better exception handling

        Show
        Jochen Theodorou added a comment - fixed due to better exception handling
        Jochen Theodorou made changes -
        Fix Version/s 1.0-JSR-1 [ 10964 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12729701 ] Default workflow, editable Closed status [ 12741744 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12967214 ] Default workflow, editable Closed status [ 12974934 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        276d 23h 22m 1 Jochen Theodorou 22/Mar/05 09:07
        Resolved Resolved Closed Closed
        982d 21h 19m 1 Paul King 30/Nov/07 06:26

          People

          • Assignee:
            Jochen Theodorou
            Reporter:
            Erik Husby
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development