Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.2
-
Fix Version/s: 1.7.3, 1.6.9, 1.8-beta-1
-
Component/s: None
-
Labels:None
-
Environment:Mac OSX 10.6 with Java 1.6
-
Testcase included:yes
-
Number of attachments :
Description
The following code reproduce the error:
class Foo {}
Foo.metaClass.invokeMethod = { String name, args ->
for (arg in args)
}
def f = new Foo()
f.echo(f as Foo)
Recording here the issue originally raised by Paulo on the mailing list
class Foo { def echo() { println 10 } } class Bar {} Foo.metaClass.invokeMethod = { String name, args -> for (arg in args) { println arg.getClass() } } def f = new Foo() // This works def bar = [key: 'foo'] as Bar f.echo(bar) // This throws a NullPointerException f.echo([key: 'foo'] as Bar)The example raised in the JIRA is the shortened version of the original issue but I think it's not the same because in my shortened example "asType" call also goes through overridden invokeMethod and since that does not delegate any further to do the actual asType, the shortened version is a little contrived.
So, the real issue to solve is the one here in the comment (raised originally on the mailing list by Paulo).