jdaugherty opened a new pull request, #3086:
URL: https://github.com/apache/groovy/pull/3086

   GROOVY-12191 scoped call-site invalidation to the receiver's class, and a 
change to a metaclass retires the domain of the class it belongs to. A receiver 
can use the metaclass of another class: Spock's `Mock()` and many proxy 
libraries generate a subclass whose `getMetaClass()` answers the metaclass of 
the type it stands in for. Changing that metaclass, such as replacing an 
`ExpandoMetaClass` method, retired only the stood-in type's domain, the 
metaclass guard still saw the same instance, and the call site kept invoking 
the replaced method. Groovy 5's global `SwitchPoint` re-linked it.
   
   When the selected metaclass belongs to a class other than the receiver's, 
`Selector` and `IndyCompoundAssign` now also capture that class's `SwitchPoint` 
before selection and guard the site with it. 
`IndyInvalidation.foreignMetaClassSwitchPointFor()` answers that switch point, 
or `null` when the metaclass belongs to the receiver's own class, so an 
ordinary call site gets no extra guard.
   
   `org.codehaus.groovy.vmplugin.v8.IndyForeignMetaClassSwitchPointTest` gives 
a subclass instance the `ExpandoMetaClass` of its superclass, replaces a method 
on it between two calls of the same site, once for a method call and once for a 
`+=` compound assignment, and expects the replacement each time. It fails 
without the fix.
   
   - Jira: [GROOVY-12558](https://issues.apache.org/jira/browse/GROOVY-12558)
   - Reproducer: 
https://github.com/jdaugherty/groovy-indy-shared-metaclass-switchpoint-reproducer
   - Backport to `GROOVY_6_0_X`: 
https://github.com/jdaugherty/groovy/commit/db6f007d8cecf67b5c1fbe16fe5c008d7917703d,
 on the branch 
[`GROOVY-12558-6_0_X`](https://github.com/jdaugherty/groovy/tree/GROOVY-12558-6_0_X).
   
   It reproduces on 6.0.0 and master with invokedynamic; 5.1.3, and Groovy 6 
with classic call sites, are not affected, so there is no 5.x backport. Could 
this be backported to 6.0.x once it is merged?
   


-- 
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]

Reply via email to