Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.1
-
None
-
groovy 1.7, jdk 1.6.20, win 7
Description
define a groovy class (an empty class declaration will do).
class TestClass0 {}
Muck with the metaclass using the class and an instance. the second closure assignment throws an exception (java.lang.ClassCastException: groovy.lang.MetaClassImpl cannot be cast to groovy.lang.GroovyObject at org.codehaus.groovy.runtime.HandleMetaClass.replaceDelegate(HandleMetaClass.java:71)).
void testSomething1() {
def inst = new TestClass0();
TestClass0.metaClass.addedMethod0 =
inst.metaClass.addedMethod1 =
{ return 'hello1'}}
note that simply changing the order of the closure assignments executes without throwing exceptions.