Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.8-rc-4, 1.9-beta-1, 1.7.11
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
There is a regression whereby you cannot override methods using ExpandoMetaClass.
The reason is that ClosureMetaMethod.createMethodList creates an anonymous inner class of type MetaMethod and adds it to the returned List<MetaMethod> that are to be registered
Later the isNonRealMethod(MetaMethod) check in MetaMethodIndex does this check:
private boolean isNonRealMethod(MetaMethod method) {
return method instanceof NewInstanceMetaMethod ||
method instanceof NewStaticMetaMethod ||
method instanceof ClosureMetaMethod ||
method instanceof GeneratedMetaMethod ||
method instanceof ClosureStaticMetaMethod ||
method instanceof MixinInstanceMetaMethod;
}
Since the anonymous inner MetaMethod defined in ClosureMetaMethod is not an instance of any of these types then the method is never registered in the MetaMethodIndex:
if (methodC == matchC) {
if (isNonRealMethod(method)) {
list.set(found, method);
}
Graeme, if I understand you right, then the change you are speaking of is from Dez 11 2008 and a reaction to
GROOVY-2951. That means that every 1.7 version has this bug, since this one was for 1.7 beta1. You said it was an regression, but really since back then? The changes in MetaMethodIndex go back to even July 15 2008 and the class was not touched since then. Can you provide a test case?