Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.7.1
-
Fix Version/s: 1.7.2, 1.8-beta-1
-
Component/s: None
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
There seems to be an issue with constructors added via metaclass and cleanup:
class MetaClassMagicTests extends GroovyTestCase { void testIt() { ExpandoMetaClass.enableGlobally() // Child.metaClass // uncomment and everything works // Save the old meta class def oldMetaClass = Parent.metaClass // Install a new one def emc = new ExpandoMetaClass(Parent, true, true) emc.initialize() GroovySystem.metaClassRegistry.setMetaClass(Parent, emc) // Install a map based constructor emc.constructor = { Map m -> Parent.newInstance() } // Parent constructor is used, all good assert new Child([:]) instanceof Parent // Reinstate the old meta class GroovySystem.metaClassRegistry.removeMetaClass(Parent) GroovySystem.metaClassRegistry.setMetaClass(Parent, oldMetaClass) // This fails, this calls the custom constructor from above and returns an instance of Parent assert new Child([:]) instanceof Child } } class Parent { def a } class Child extends Parent { def b }
Issue Links
- is related to
-
GRAILS-5883
Order of Unit Test matters when one Domain class extends other Domain class
-