-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
ClosureMetaClass.java
712 lines (637 loc) · 28.8 KB
/
ClosureMetaClass.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.codehaus.groovy.runtime.metaclass;
import groovy.lang.Closure;
import groovy.lang.ExpandoMetaClass;
import groovy.lang.GroovyObject;
import groovy.lang.GroovyRuntimeException;
import groovy.lang.MetaBeanProperty;
import groovy.lang.MetaClass;
import groovy.lang.MetaClassImpl;
import groovy.lang.MetaClassRegistry;
import groovy.lang.MetaMethod;
import groovy.lang.MetaProperty;
import groovy.lang.MissingMethodException;
import groovy.lang.MissingPropertyException;
import groovy.lang.ProxyMetaClass;
import org.codehaus.groovy.reflection.CachedClass;
import org.codehaus.groovy.reflection.CachedField;
import org.codehaus.groovy.reflection.CachedMethod;
import org.codehaus.groovy.reflection.ParameterTypes;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.codehaus.groovy.runtime.MetaClassHelper;
import org.codehaus.groovy.runtime.callsite.CallSite;
import org.codehaus.groovy.runtime.callsite.PogoMetaClassSite;
import org.codehaus.groovy.runtime.wrappers.Wrapper;
import org.codehaus.groovy.util.FastArray;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* A meta class for closures generated by the Groovy compiler. These classes
* have special characteristics this MetaClass uses. One of these is that a
* generated Closure has only additional doCall methods, all other methods
* are in the Closure class as well. To use this fact this MetaClass uses
* a MetaClass for Closure as static field And delegates calls to this
* MetaClass if needed. This allows a lean implementation for this MetaClass.
* Multiple generated closures will then use the same MetaClass for Closure.
* For static dispatching this class uses the MetaClass of Class, again
* all instances of this class will share that MetaClass. The Class MetaClass
* is initialized lazy, because most operations do not need this MetaClass.
* <p>
* The Closure and Class MetaClasses are not replaceable.
* <p>
* This MetaClass is for internal usage only!
*
* @since 1.5
*/
public final class ClosureMetaClass extends MetaClassImpl {
private volatile boolean initialized;
private final FastArray closureMethods = new FastArray(3);
private Map<String, CachedField> attributes = new HashMap<String, CachedField>();
private MethodChooser chooser;
private volatile boolean attributeInitDone = false;
private static MetaClassImpl CLOSURE_METACLASS;
private static MetaClassImpl classMetaClass;
private static final Object[] EMPTY_ARGUMENTS = {};
private static final String CLOSURE_CALL_METHOD = "call";
private static final String CLOSURE_DO_CALL_METHOD = "doCall";
static {
resetCachedMetaClasses();
}
public static void resetCachedMetaClasses() {
MetaClassImpl temp = new MetaClassImpl(Closure.class);
temp.initialize();
synchronized (ClosureMetaClass.class) {
CLOSURE_METACLASS = temp;
}
if (classMetaClass!=null) {
temp = new MetaClassImpl(Class.class);
temp.initialize();
synchronized (ClosureMetaClass.class) {
classMetaClass = temp;
}
}
}
private static synchronized MetaClass getStaticMetaClass() {
if (classMetaClass == null) {
classMetaClass = new MetaClassImpl(Class.class);
classMetaClass.initialize();
}
return classMetaClass;
}
private interface MethodChooser {
Object chooseMethod(Class[] arguments, boolean coerce);
}
private static class StandardClosureChooser implements MethodChooser {
private final MetaMethod doCall0;
private final MetaMethod doCall1;
StandardClosureChooser(MetaMethod m0, MetaMethod m1) {
doCall0 = m0;
doCall1 = m1;
}
public Object chooseMethod(Class[] arguments, boolean coerce) {
if (arguments.length == 0) return doCall0;
if (arguments.length == 1) return doCall1;
return null;
}
}
private static class NormalMethodChooser implements MethodChooser {
private final FastArray methods;
final Class theClass;
NormalMethodChooser(Class theClass, FastArray methods) {
this.theClass = theClass;
this.methods = methods;
}
public Object chooseMethod(Class[] arguments, boolean coerce) {
if (arguments.length == 0) {
return MetaClassHelper.chooseEmptyMethodParams(methods);
} else if (arguments.length == 1 && arguments[0] == null) {
return MetaClassHelper.chooseMostGeneralMethodWith1NullParam(methods);
} else {
List matchingMethods = new ArrayList();
final Object[] data = methods.getArray();
for (int i = 0, len = methods.size(); i != len; ++i) {
Object method = data[i];
// making this false helps find matches
if (((ParameterTypes) method).isValidMethod(arguments)) {
matchingMethods.add(method);
}
}
int size = matchingMethods.size();
if (0 == size) {
return null;
} else if (1 == size) {
return matchingMethods.get(0);
}
return chooseMostSpecificParams(CLOSURE_DO_CALL_METHOD, matchingMethods, arguments);
}
}
private Object chooseMostSpecificParams(String name, List matchingMethods, Class[] arguments) {
return doChooseMostSpecificParams(theClass.getName(), name, matchingMethods, arguments, true);
}
}
public ClosureMetaClass(MetaClassRegistry registry, Class theClass) {
super(registry, theClass);
}
public MetaProperty getMetaProperty(String name) {
return CLOSURE_METACLASS.getMetaProperty(name);
}
private static void unwrap(Object[] arguments) {
for (int i = 0; i != arguments.length; i++) {
if (arguments[i] instanceof Wrapper) {
arguments[i] = ((Wrapper) arguments[i]).unwrap();
}
}
}
private MetaMethod pickClosureMethod(Class[] argClasses) {
Object answer = chooser.chooseMethod(argClasses, false);
return (MetaMethod) answer;
}
private MetaMethod getDelegateMethod(Closure closure, Object delegate, String methodName, Class[] argClasses) {
if (delegate == closure || delegate == null) return null;
if (delegate instanceof Class) {
for (Class superClass = (Class) delegate;
superClass != Object.class && superClass != null;
superClass = superClass.getSuperclass())
{
MetaClass mc = registry.getMetaClass(superClass);
MetaMethod method = mc.getStaticMetaMethod(methodName, argClasses);
if (method != null) return method;
}
return null;
} else {
MetaClass delegateMetaClass = lookupObjectMetaClass(delegate);
MetaMethod method = delegateMetaClass.pickMethod(methodName, argClasses);
if (method != null) {
return method;
}
if (delegateMetaClass instanceof ExpandoMetaClass) {
method = ((ExpandoMetaClass) delegateMetaClass).findMixinMethod(methodName, argClasses);
if (method != null) {
onMixinMethodFound(method);
return method;
}
}
if (delegateMetaClass instanceof MetaClassImpl) {
method = MetaClassImpl.findMethodInClassHierarchy(getTheClass(), methodName, argClasses, this);
if (method != null) {
onSuperMethodFoundInHierarchy(method);
return method;
}
}
return method;
}
}
public Object invokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass) {
checkInitalised();
if (object == null) {
throw new NullPointerException("Cannot invoke method: " + methodName + " on null object");
}
final Object[] arguments = makeArguments(originalArguments, methodName);
final Class[] argClasses = MetaClassHelper.convertToTypeArray(arguments);
unwrap(arguments);
MetaMethod method = null;
final Closure closure = (Closure) object;
if (CLOSURE_DO_CALL_METHOD.equals(methodName) || CLOSURE_CALL_METHOD.equals(methodName)) {
method = pickClosureMethod(argClasses);
if (method == null && arguments.length == 1 && arguments[0] instanceof List) {
Object[] newArguments = ((List) arguments[0]).toArray();
Class[] newArgClasses = MetaClassHelper.convertToTypeArray(newArguments);
method = createTransformMetaMethod(pickClosureMethod(newArgClasses));
}
if (method == null) throw new MissingMethodException(methodName, theClass, arguments, false);
}
boolean shouldDefer = closure.getResolveStrategy() == Closure.DELEGATE_ONLY && isInternalMethod(methodName);
if (method == null && !shouldDefer) {
method = CLOSURE_METACLASS.pickMethod(methodName, argClasses);
}
if (method != null) return method.doMethodInvoke(object, arguments);
MissingMethodException last = null;
Object callObject = object;
final Object owner = closure.getOwner();
final Object delegate = closure.getDelegate();
final Object thisObject = closure.getThisObject();
final int resolveStrategy = closure.getResolveStrategy();
boolean invokeOnDelegate = false;
boolean invokeOnOwner = false;
boolean ownerFirst = true;
switch (resolveStrategy) {
case Closure.TO_SELF:
break;
case Closure.DELEGATE_ONLY:
method = getDelegateMethod(closure, delegate, methodName, argClasses);
callObject = delegate;
if (method == null) {
invokeOnDelegate = delegate != closure && (delegate instanceof GroovyObject);
}
break;
case Closure.OWNER_ONLY:
method = getDelegateMethod(closure, owner, methodName, argClasses);
callObject = owner;
if (method == null) {
invokeOnOwner = owner != closure && (owner instanceof GroovyObject);
}
break;
case Closure.DELEGATE_FIRST:
method = getDelegateMethod(closure, delegate, methodName, argClasses);
callObject = delegate;
if (method == null) {
method = getDelegateMethod(closure, owner, methodName, argClasses);
callObject = owner;
}
if (method == null) {
invokeOnDelegate = delegate != closure && (delegate instanceof GroovyObject);
invokeOnOwner = owner != closure && (owner instanceof GroovyObject);
ownerFirst = false;
}
break;
default: // owner first
// owner first means we start with the outer most owner that is not a generated closure
// this owner is equal to the this object, so we check that one first.
method = getDelegateMethod(closure, thisObject, methodName, argClasses);
callObject = thisObject;
if (method == null) {
// try finding a delegate that has that method... we start from
// outside building a stack and try each delegate
LinkedList list = new LinkedList();
for (Object current = closure; current != thisObject;) {
if (!(current instanceof Closure)) break;
Closure currentClosure = (Closure) current;
if (currentClosure.getDelegate() != null) list.add(current);
current = currentClosure.getOwner();
}
while (!list.isEmpty() && method == null) {
Closure closureWithDelegate = (Closure) list.removeLast();
Object currentDelegate = closureWithDelegate.getDelegate();
method = getDelegateMethod(closureWithDelegate, currentDelegate, methodName, argClasses);
callObject = currentDelegate;
}
}
if (method == null) {
invokeOnDelegate = delegate != closure && (delegate instanceof GroovyObject);
invokeOnOwner = owner != closure && (owner instanceof GroovyObject);
}
}
if (method == null && (invokeOnOwner || invokeOnDelegate)) {
try {
if (ownerFirst) {
return invokeOnDelegationObjects(invokeOnOwner, owner, invokeOnDelegate, delegate, methodName, arguments);
} else {
return invokeOnDelegationObjects(invokeOnDelegate, delegate, invokeOnOwner, owner, methodName, arguments);
}
} catch (MissingMethodException mme) {
last = mme;
}
}
if (method != null) {
MetaClass metaClass = registry.getMetaClass(callObject.getClass());
if (metaClass instanceof ProxyMetaClass) {
return metaClass.invokeMethod(callObject, methodName, arguments);
} else {
return method.doMethodInvoke(callObject, arguments);
}
} else {
// if no method was found, try to find a closure defined as a field of the class and run it
Object value = null;
try {
value = this.getProperty(object, methodName);
} catch (MissingPropertyException mpe) {
// ignore
}
if (value instanceof Closure) { // This test ensures that value != this If you ever change this ensure that value != this
Closure cl = (Closure) value;
MetaClass delegateMetaClass = cl.getMetaClass();
return delegateMetaClass.invokeMethod(cl.getClass(), closure, CLOSURE_DO_CALL_METHOD, originalArguments, false, fromInsideClass);
}
}
if (last != null) throw last;
throw new MissingMethodException(methodName, theClass, arguments, false);
}
private static boolean isInternalMethod(String methodName) {
return methodName.equals("curry") || methodName.equals("ncurry") || methodName.equals("rcurry") ||
methodName.equals("leftShift") || methodName.equals("rightShift");
}
private static Object[] makeArguments(Object[] arguments, String methodName) {
if (arguments == null) return EMPTY_ARGUMENTS;
return arguments;
}
private static Throwable unwrap(GroovyRuntimeException gre) {
Throwable th = gre;
if (th.getCause() != null && th.getCause() != gre) th = th.getCause();
if (th != gre && (th instanceof GroovyRuntimeException)) return unwrap((GroovyRuntimeException) th);
return th;
}
private static Object invokeOnDelegationObjects(
boolean invoke1, Object o1,
boolean invoke2, Object o2,
String methodName, Object[] args) {
MissingMethodException first = null;
if (invoke1) {
GroovyObject go = (GroovyObject) o1;
try {
return go.invokeMethod(methodName, args);
} catch (MissingMethodException mme) {
first = mme;
} catch (GroovyRuntimeException gre) {
Throwable th = unwrap(gre);
if ((th instanceof MissingMethodException)
&& (methodName.equals(((MissingMethodException) th).getMethod()))) {
first = (MissingMethodException) th;
} else {
throw gre;
}
}
}
if (invoke2 && (!invoke1 || o1 != o2)) {
GroovyObject go = (GroovyObject) o2;
try {
return go.invokeMethod(methodName, args);
} catch (MissingMethodException mme) {
// patch needed here too, but we need a test case to trip it first
if (first == null) first = mme;
} catch (GroovyRuntimeException gre) {
Throwable th = unwrap(gre);
if (th instanceof MissingMethodException) {
first = (MissingMethodException) th;
} else {
throw gre;
}
}
}
throw first;
}
private synchronized void initAttributes() {
if (!attributes.isEmpty()) return;
attributes.put("!", null); // just a dummy for later
CachedField[] fieldArray = theCachedClass.getFields();
for (CachedField aFieldArray : fieldArray) {
attributes.put(aFieldArray.getName(), aFieldArray);
}
attributeInitDone = !attributes.isEmpty();
}
public synchronized void initialize() {
if (!isInitialized()) {
CachedMethod[] methodArray = theCachedClass.getMethods();
synchronized (theCachedClass) {
for (final CachedMethod cachedMethod : methodArray) {
if (!cachedMethod.getName().equals(CLOSURE_DO_CALL_METHOD)) continue;
closureMethods.add(cachedMethod);
}
}
assignMethodChooser();
initialized = true;
}
}
private void assignMethodChooser() {
if (closureMethods.size() == 1) {
final MetaMethod doCall = (MetaMethod) closureMethods.get(0);
final CachedClass[] c = doCall.getParameterTypes();
int length = c.length;
if (length == 0) {
// no arg method
chooser = new MethodChooser() {
public Object chooseMethod(Class[] arguments, boolean coerce) {
if (arguments.length == 0) return doCall;
return null;
}
};
} else {
if (length == 1 && c[0].getTheClass() == Object.class) {
// Object fits all, so simple dispatch rule here
chooser = new MethodChooser() {
public Object chooseMethod(Class[] arguments, boolean coerce) {
// <2, because foo() is same as foo(null)
if (arguments.length < 2) return doCall;
return null;
}
};
} else {
boolean allObject = true;
for (int i = 0; i < c.length - 1; i++) {
if (c[i].getTheClass() != Object.class) {
allObject = false;
break;
}
}
if (allObject && c[c.length - 1].getTheClass() == Object.class) {
// all arguments are object, so test only if argument number is correct
chooser = new MethodChooser() {
public Object chooseMethod(Class[] arguments, boolean coerce) {
if (arguments.length == c.length) return doCall;
return null;
}
};
} else {
if (allObject && c[c.length - 1].getTheClass() == Object[].class) {
// all arguments are Object but last, which is a vargs argument, that
// will fit all, so just test if the number of argument is equal or
// more than the parameters we have.
final int minimumLength = c.length - 2;
chooser = new MethodChooser() {
public Object chooseMethod(Class[] arguments, boolean coerce) {
if (arguments.length > minimumLength) return doCall;
return null;
}
};
} else {
// general case for single method
chooser = new MethodChooser() {
public Object chooseMethod(Class[] arguments, boolean coerce) {
if (doCall.isValidMethod(arguments)) {
return doCall;
}
return null;
}
};
}
}
}
}
} else if (closureMethods.size() == 2) {
MetaMethod m0 = null, m1 = null;
for (int i = 0; i != closureMethods.size(); ++i) {
MetaMethod m = (MetaMethod) closureMethods.get(i);
CachedClass[] c = m.getParameterTypes();
if (c.length == 0) {
m0 = m;
} else {
if (c.length == 1 && c[0].getTheClass() == Object.class) {
m1 = m;
}
}
}
if (m0 != null && m1 != null) {
// standard closure (2 methods because "it" is with default null)
chooser = new StandardClosureChooser(m0, m1);
}
}
if (chooser == null) {
// standard chooser for cases if it is not a single method and if it is
// not the standard closure.
chooser = new NormalMethodChooser(theClass, closureMethods);
}
}
private MetaClass lookupObjectMetaClass(Object object) {
if (object instanceof GroovyObject) {
GroovyObject go = (GroovyObject) object;
return go.getMetaClass();
}
Class ownerClass = object.getClass();
if (ownerClass == Class.class) {
ownerClass = (Class) object;
return registry.getMetaClass(ownerClass);
}
MetaClass metaClass = InvokerHelper.getMetaClass(object);
return metaClass;
}
@Override
public List<MetaMethod> getMethods() {
List<MetaMethod> answer = CLOSURE_METACLASS.getMetaMethods();
answer.addAll(closureMethods.toList());
return answer;
}
@Override
public List<MetaMethod> getMetaMethods() {
return CLOSURE_METACLASS.getMetaMethods();
}
@Override
public List<MetaProperty> getProperties() {
return CLOSURE_METACLASS.getProperties();
}
@Override
public MetaMethod pickMethod(String name, Class[] argTypes) {
if (argTypes == null) argTypes = MetaClassHelper.EMPTY_CLASS_ARRAY;
if (name.equals(CLOSURE_CALL_METHOD) || name.equals(CLOSURE_DO_CALL_METHOD)) {
return pickClosureMethod(argTypes);
}
return CLOSURE_METACLASS.getMetaMethod(name, argTypes);
}
public MetaMethod retrieveStaticMethod(String methodName, Class[] arguments) {
return null;
}
protected boolean isInitialized() {
return initialized;
}
public MetaMethod getStaticMetaMethod(String name, Object[] args) {
return CLOSURE_METACLASS.getStaticMetaMethod(name, args);
}
public MetaMethod getStaticMetaMethod(String name, Class[] argTypes) {
return CLOSURE_METACLASS.getStaticMetaMethod(name, argTypes);
}
public Object getProperty(Class sender, Object object, String name, boolean useSuper, boolean fromInsideClass) {
if (object instanceof Class) {
return getStaticMetaClass().getProperty(sender, object, name, useSuper, fromInsideClass);
} else {
return CLOSURE_METACLASS.getProperty(sender, object, name, useSuper, fromInsideClass);
}
}
@Override
public Object getAttribute(Class sender, Object object, String attribute, boolean useSuper, boolean fromInsideClass) {
if (object instanceof Class) {
return getStaticMetaClass().getAttribute(sender, object, attribute, useSuper);
} else {
if (!attributeInitDone) initAttributes();
CachedField mfp = attributes.get(attribute);
if (mfp == null) {
return CLOSURE_METACLASS.getAttribute(sender, object, attribute, useSuper);
} else {
return mfp.getProperty(object);
}
}
}
@Override
public void setAttribute(Class sender, Object object, String attribute,
Object newValue, boolean useSuper, boolean fromInsideClass) {
if (object instanceof Class) {
getStaticMetaClass().setAttribute(sender, object, attribute, newValue, useSuper, fromInsideClass);
} else {
if (!attributeInitDone) initAttributes();
CachedField mfp = attributes.get(attribute);
if (mfp == null) {
CLOSURE_METACLASS.setAttribute(sender, object, attribute, newValue, useSuper, fromInsideClass);
} else {
mfp.setProperty(object, newValue);
}
}
}
public Object invokeStaticMethod(Object object, String methodName, Object[] arguments) {
return getStaticMetaClass().invokeMethod(Class.class, object, methodName, arguments, false, false);
}
public void setProperty(Class sender, Object object, String name, Object newValue, boolean useSuper, boolean fromInsideClass) {
if (object instanceof Class) {
getStaticMetaClass().setProperty(sender, object, name, newValue, useSuper, fromInsideClass);
} else {
CLOSURE_METACLASS.setProperty(sender, object, name, newValue, useSuper, fromInsideClass);
}
}
public MetaMethod getMethodWithoutCaching(int index, Class sender, String methodName, Class[] arguments, boolean isCallToSuper) {
throw new UnsupportedOperationException();
}
public void setProperties(Object bean, Map map) {
throw new UnsupportedOperationException();
}
public void addMetaBeanProperty(MetaBeanProperty mp) {
throw new UnsupportedOperationException();
}
public void addMetaMethod(MetaMethod method) {
throw new UnsupportedOperationException();
}
public void addNewInstanceMethod(Method method) {
throw new UnsupportedOperationException();
}
public void addNewStaticMethod(Method method) {
throw new UnsupportedOperationException();
}
public Constructor retrieveConstructor(Class[] arguments) {
throw new UnsupportedOperationException();
}
public CallSite createPojoCallSite(CallSite site, Object receiver, Object[] args) {
throw new UnsupportedOperationException();
}
public CallSite createPogoCallSite(CallSite site, Object[] args) {
return new PogoMetaClassSite(site, this);
}
public CallSite createPogoCallCurrentSite(CallSite site, Class sender, Object[] args) {
return new PogoMetaClassSite(site, this);
}
public List respondsTo(Object obj, String name, Object[] argTypes) {
loadMetaInfo();
return super.respondsTo(obj, name, argTypes);
}
public List respondsTo(final Object obj, final String name) {
loadMetaInfo();
return super.respondsTo(obj, name);
}
private synchronized void loadMetaInfo() {
if (metaMethodIndex.isEmpty()) {
initialized = false;
super.initialize();
initialized = true;
}
}
protected void applyPropertyDescriptors(PropertyDescriptor[] propertyDescriptors) {
// do nothing
}
}