Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-5
-
None
Description
Static closures have their owner object set to the equivalent of java.lang.Class.class instead of the class they're contained in.
Example:
class Test {
static staticMethod()
static void main(args) {
c =
c()
}
}
Fails with:
Caught: groovy.lang.MissingMethodException: No such method: staticMethod for class: Test$1 with arguments: []
Patch:
Index: ClassGenerator.java
===================================================================
retrieving revision 1.175
diff -u -r1.175 ClassGenerator.java
— ClassGenerator.java 25 Mar 2004 19:29:58 -0000 1.175
+++ ClassGenerator.java 26 Mar 2004 14:52:49 -0000
@@ -1126,9 +1126,6 @@
ClassNode owner = innerClass.getOuterClass();
String ownerTypeName = owner.getName();
- if (classNode.isStaticClass() || isStaticMethod()) { - ownerTypeName = "java.lang.Class"; - }
passingClosureParams = true;
List constructors = innerClass.getDeclaredConstructors();