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

GString doesn't call correct toString method when it's been changed via the metaClass mechanism

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.5.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    linux
  • Testcase included:
    yes
  • Patch Submitted:
    Yes

Description

This is best shown by a small example. I've attached a trivial patch as well.

class A {
String toString() { "unchanged"; }
}

A.metaClass.toString = { ->
"changed";
}

def a = new A();
println a.toString();
println "${a}";

brandon@Brandon:~/localtmp/groovy-1.5.4$ unset GROOVY_HOME
brandon@Brandon:~/localtmp/groovy-1.5.4$ groovy-unpatched test.groovy
changed
unchanged
brandon@Brandon:~/localtmp/groovy-1.5.4$ groovy test.groovy
changed
changed

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    gstring.patch
    08/Apr/08 3:55 PM
    0.4 kB
    brandon niemczyk

Issue Links

duplicates

Bug - A problem which impairs or prevents the functions of the product. GROOVY-2599 unable to overwritel toString() via MOP in some cases

  • Major - Major loss of function.
  • Open - The issue is open and ready for the assignee to start work on it.

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
There are no comments yet on this issue.

People

  • Assignee:
    Unassigned
    Reporter:
    brandon niemczyk
Vote (0)
Watch (0)

Dates

  • Created:
    08/Apr/08 3:55 PM
    Updated:
    08/Apr/08 4:57 PM
    Resolved:
    08/Apr/08 4:57 PM
  • 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.