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-134

New "def" has short term memory in shell

  • 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.1-rc-3
  • Component/s: None
  • Labels:
    None

Description

groovy> def foo { println(x) }
groovy>
null
groovy> foo(5)
groovy>
Caught: groovy.lang.MissingMethodException: No such method: foo for class: CommandLine2 with arguments: [5]
groovy.lang.MissingMethodException: No such method: foo for class: CommandLine2 with arguments: [5]
at groovy.lang.MetaClass.invokeStaticMethod(MetaClass.java:285)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:241)
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 groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:758)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:214)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:130)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:95)
at CommandLine2.invokeMethod(CommandLine2.groovy)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:117)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:95)
at CommandLine2.run(CommandLine2.groovy)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:236)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:215)
at groovy.ui.InteractiveShell.run(InteractiveShell.java:100)
at groovy.ui.InteractiveShell.main(InteractiveShell.java:71)
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)

Issue Links

is depended upon by

Task - A task that needs to be done. GROOVY-756 improve GroovyShell

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Kim, Pilho added a comment - 12/Jun/05 11:39 PM

I have tested the above code with command "groovysh" on JSR-02 (CVS HEAD build).
But I could not found such an error.

$ groovysh
Lets get Groovy!
================
Version: 1.0-jsr-02-SNAPSHOT JVM: 1.4.2_07-b05
Type 'exit' to terminate the shell
Type 'help' for command help
Type 'go' to execute the statements

groovy> def foo { println(x) }
groovy>
groovy> foo(5)
groovy>
groovy> go
5

Show
Kim, Pilho added a comment - 12/Jun/05 11:39 PM I have tested the above code with command "groovysh" on JSR-02 (CVS HEAD build). But I could not found such an error. $ groovysh Lets get Groovy! ================ Version: 1.0-jsr-02-SNAPSHOT JVM: 1.4.2_07-b05 Type 'exit' to terminate the shell Type 'help' for command help Type 'go' to execute the statements groovy> def foo { println(x) } groovy> groovy> foo(5) groovy> groovy> go 5
Hide
Permalink
Alan Green added a comment - 14/Nov/05 4:46 AM

This isn't so much a bug as a limitation of Groovy. Each time the user types 'go', the code is compiled into a script. Each script is compiled into its own class executed and forgotten.

If you need this functionality, consider using the Swing console, which is much more amenable to reusing snippets of code.

Show
Alan Green added a comment - 14/Nov/05 4:46 AM This isn't so much a bug as a limitation of Groovy. Each time the user types 'go', the code is compiled into a script. Each script is compiled into its own class executed and forgotten. If you need this functionality, consider using the Swing console, which is much more amenable to reusing snippets of code.
Hide
Permalink
Joćo O.C.V.B. Campos added a comment - 29/Dec/05 9:58 AM

That renders the groovy shell as pratically useless. I can't think of any use for an interpreter shell for creating small scripts in the style of primitive line editors. One could do much better with a text editor and the groovy command line or, as you say, with the groovy Swing console.

The purpose of script languages interpreter shells is to be able to add and change code on-the-fly, allowing testing and implementing small changes without having to execute the whole thing again. Most modern renowned script languages include this facility; these include: Python (and Jython), Ruby (and JRuby), BeanShell, Rhino, etc.

Show
Joćo O.C.V.B. Campos added a comment - 29/Dec/05 9:58 AM That renders the groovy shell as pratically useless. I can't think of any use for an interpreter shell for creating small scripts in the style of primitive line editors. One could do much better with a text editor and the groovy command line or, as you say, with the groovy Swing console. The purpose of script languages interpreter shells is to be able to add and change code on-the-fly, allowing testing and implementing small changes without having to execute the whole thing again. Most modern renowned script languages include this facility; these include: Python (and Jython), Ruby (and JRuby), BeanShell, Rhino, etc.
Hide
Permalink
Guillaume Laforge added a comment - 02/Nov/07 5:01 AM

The new interactive shell solves this problem.

Show
Guillaume Laforge added a comment - 02/Nov/07 5:01 AM The new interactive shell solves this problem.

People

  • Assignee:
    Jason Dillon
    Reporter:
    Rod Cope
Vote (1)
Watch (2)

Dates

  • Created:
    16/Jan/04 3:37 PM
    Updated:
    02/Nov/07 5:01 AM
    Resolved:
    02/Nov/07 5:01 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.