jdaugherty commented on PR #3086: URL: https://github.com/apache/groovy/pull/3086#issuecomment-6592619926
Thanks, fair questions. GROOVY-12046 fixed a different symptom of the same receiver shape: the type MetaClassImpl.invokeMissingMethod reports, so the indy fallback reaches GroovyObject.invokeMethod (merged June, 6.0.0-alpha-2). GROOVY-12558 comes from GROOVY-12191 (6.0.0-beta-1, August): a site is guarded by the SwitchPoint of the receiver's class, while an ExpandoMetaClass edit retires only the domain of mc.getTheClass() (ClassInfo.incVersion -> IndyInvalidation.invalidateClass). 12046 predates that. I agree MetaClassImpl and ExpandoMetaClass were not designed to stand in for another class. But frameworks create this shape, not test code: Spock's Mock() answers getMetaClass() with the mocked type's registry metaclass (JavaMockFactory/JavaMockInterceptor), GORM's Hibernate proxies return InvokerHelper.getMetaClass(persistentClass), and a Spring CGLIB proxy of a Groovy bean delegates getMetaClass() to its target. Groovy 5 handled these receivers. The fix is not ExpandoMetaClass-specific: it compares mc.getTheClass() with the receiver's class. ExpandoMetaClass is the common trigger because it is edited in place, so the same-metaclass guard still passes. DelegatingMetaClass and custom metaclasses are not affected, before or after this PR: the selector links directly only for MetaClassImpl/ExpandoMetaClass, and any other metaclass is called through mc.invokeMethod on every call. Spock's GroovyMock() uses such a metaclass. Replacing greet() between two calls of one site, indy on: | Receiver | 5.1.3 | 6.0.0 | master | with this PR | |---|---|---|---|---| | subclass holding the type's ExpandoMetaClass (Spock Mock()) | OK | stale | stale | OK | | subclass answering the type's registry metaclass (GORM proxy) | | Spring CGLIB proxy of a Groovy bean | OK | stale | stale | OK | | DelegatingMetaClass over the type's ExpandoMetaClass | OK | OK | custom metaclass | OK | OK | OK | OK | I can add the DelegatingMetaClass case and the registry-answering proxy to the test so it covers more than one shape. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
