Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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.
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...