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

Method closures don't work for static methods

  • 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:
    WinXP, JDK1.4.2_03

Description

Trying to create a method closure from a staic metod fails...

y = (new Object()).hashCode
println y()
//succeeds

x = System.currentTimeMillis
println x()
// fails with
// "No such property: currentTimeMillis for class: java.lang.System. Reason: java.lang.NoSuchFieldException: currentTimeMillis"

Also... I don't think 'use' is too wild about static methods either.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
John Stump added a comment - 24/Aug/04 1:28 PM

This is related to issue 515: Groovy's syntax introduces conflicts between accessing static fields of a class and accessing members of the Class object of a class.

For instance:

println System.name prints java.lang.System because this "property" is pulled from the Class object of java.lang.System. However, it is impossible to get an actual static property from System, like currentMillis, because it always gets deferred to the Class object, not the static object.

I believe this fix requires a change in syntax; therefore, I'm throwing this issue back up to unassigned...

Show
John Stump added a comment - 24/Aug/04 1:28 PM This is related to issue 515: Groovy's syntax introduces conflicts between accessing static fields of a class and accessing members of the Class object of a class. For instance: println System.name prints java.lang.System because this "property" is pulled from the Class object of java.lang.System. However, it is impossible to get an actual static property from System, like currentMillis, because it always gets deferred to the Class object, not the static object. I believe this fix requires a change in syntax; therefore, I'm throwing this issue back up to unassigned...
Hide
Permalink
blackdrag blackdrag added a comment - 05/Apr/05 6:09 AM

y = (new Object()).&hashCode
println y()
x = System.&currentTimeMillis
println x()

is the version with the new syntax and is working fine

Show
blackdrag blackdrag added a comment - 05/Apr/05 6:09 AM y = (new Object()).&hashCode println y() x = System.&currentTimeMillis println x() is the version with the new syntax and is working fine

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    Danno Ferrin
Vote (0)
Watch (0)

Dates

  • Created:
    19/May/04 12:39 AM
    Updated:
    30/Nov/07 6:27 AM
    Resolved:
    05/Apr/05 6:09 AM

Time Tracking

Estimated:
2d
Original Estimate - 2 days
Remaining:
2d
Remaining Estimate - 2 days
Logged:
Not Specified
Time Spent - Not Specified
  • 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.