jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-543

Incorrect exception MissingMethodException when closure references an uninitialized variable

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed 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

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
blackdrag blackdrag added a comment - 22/Mar/05 9:07 AM

fixed due to better exception handling

Show
blackdrag blackdrag added a comment - 22/Mar/05 9:07 AM fixed due to better exception handling

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    Erik Husby
Vote (0)
Watch (0)

Dates

  • Created:
    18/Jun/04 9:44 AM
    Updated:
    30/Nov/07 6:26 AM
    Resolved:
    22/Mar/05 9:07 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.