77import com .llamalad7 .mixinextras .injector .wrapmethod .WrapMethod ;
88import com .llamalad7 .mixinextras .injector .wrapoperation .Operation ;
99import groovy .lang .*;
10+ import org .codehaus .groovy .reflection .CachedClass ;
1011import org .codehaus .groovy .runtime .metaclass .MetaClassRegistryImpl ;
1112import org .spongepowered .asm .mixin .*;
1213import org .spongepowered .asm .mixin .Mixin ;
@@ -36,9 +37,6 @@ protected abstract Object invokeMissingMethod(Object instance,
3637 RuntimeException original ,
3738 boolean isCallToSuper );
3839
39- @ Shadow
40- protected abstract MetaProperty getMetaProperty (String name , boolean useStatic );
41-
4240 @ Mutable
4341 @ Shadow
4442 @ Final
@@ -52,6 +50,14 @@ protected abstract Object invokeMissingMethod(Object instance,
5250 @ Shadow
5351 protected MetaClassRegistry registry ;
5452
53+ @ Shadow
54+ @ Final
55+ private Map <CachedClass , Map <String , MetaProperty >> classPropertyIndex ;
56+
57+ @ Shadow
58+ @ Final
59+ protected CachedClass theCachedClass ;
60+
5561 @ Inject (method = "<init>(Ljava/lang/Class;[Lgroovy/lang/MetaMethod;)V" , at = @ At ("TAIL" ))
5662 public void removeBlacklistedAdditional (Class <?> theClass , MetaMethod [] add , CallbackInfo ci ) {
5763 if (additionalMetaMethods .length > 0 ) {
@@ -115,7 +121,10 @@ private Object invokePropertyOrMissing(Object object,
115121 Object [] originalArguments ,
116122 boolean fromInsideClass ,
117123 boolean isCallToSuper ) {
118- MetaProperty metaProperty = getMetaProperty (methodName , false );
124+ MetaProperty metaProperty = null ;
125+
126+ Map <String , MetaProperty > propertyMap = classPropertyIndex .get (theCachedClass );
127+ if (propertyMap != null ) metaProperty = propertyMap .get (methodName );
119128
120129 Object value = null ;
121130 if (metaProperty != null ) {
@@ -125,10 +134,12 @@ private Object invokePropertyOrMissing(Object object,
125134 } else if (object instanceof Script script ) {
126135 value = script .getBinding ().getVariables ().get (methodName );
127136 } else if (object instanceof GroovyObject ) {
137+ // GroovyScript: added this branch
128138 value = GroovyScript .getSandbox ().getBindings ().get (methodName );
129139 }
130140
131141 if (value instanceof Closure <?>closure ) {
142+ // GroovyScript: simplify closure call
132143 return closure .call (originalArguments );
133144 }
134145
0 commit comments