use of groovy.lang.MetaClassImpl in project groovy-core by groovy.
the class CallSiteArray method createPojoSite.
// for MetaClassImpl we try to pick meta method,
// otherwise or if method doesn't exist we make call via POJO meta class
private static CallSite createPojoSite(CallSite callSite, Object receiver, Object[] args) {
final Class klazz = receiver.getClass();
MetaClass metaClass = InvokerHelper.getMetaClass(receiver);
if (!GroovyCategorySupport.hasCategoryInCurrentThread() && metaClass instanceof MetaClassImpl) {
final MetaClassImpl mci = (MetaClassImpl) metaClass;
final ClassInfo info = mci.getTheCachedClass().classInfo;
if (info.hasPerInstanceMetaClasses()) {
return new PerInstancePojoMetaClassSite(callSite, info);
} else {
return mci.createPojoCallSite(callSite, receiver, args);
}
}
ClassInfo info = ClassInfo.getClassInfo(klazz);
if (info.hasPerInstanceMetaClasses())
return new PerInstancePojoMetaClassSite(callSite, info);
else
return new PojoMetaClassSite(callSite, metaClass);
}
use of groovy.lang.MetaClassImpl in project groovy-core by groovy.
the class CallSiteArray method createCallStaticSite.
private static CallSite createCallStaticSite(CallSite callSite, final Class receiver, Object[] args) {
CallSite site;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
try {
Class.forName(receiver.getName(), true, receiver.getClassLoader());
} catch (Exception e) {
// force <clinit>
}
return null;
}
});
MetaClass metaClass = InvokerHelper.getMetaClass(receiver);
if (metaClass instanceof MetaClassImpl) {
site = ((MetaClassImpl) metaClass).createStaticSite(callSite, args);
} else
site = new StaticMetaClassSite(callSite, metaClass);
replaceCallSite(callSite, site);
return site;
}
use of groovy.lang.MetaClassImpl in project groovy-core by groovy.
the class CallSiteArray method createCallCurrentSite.
private static CallSite createCallCurrentSite(CallSite callSite, GroovyObject receiver, Object[] args, Class sender) {
CallSite site;
if (receiver instanceof GroovyInterceptable)
site = new PogoInterceptableSite(callSite);
else {
MetaClass metaClass = receiver.getMetaClass();
if (receiver.getClass() != metaClass.getTheClass() && !metaClass.getTheClass().isInterface()) {
site = new PogoInterceptableSite(callSite);
} else if (metaClass instanceof MetaClassImpl) {
site = ((MetaClassImpl) metaClass).createPogoCallCurrentSite(callSite, sender, args);
} else
site = new PogoMetaClassSite(callSite, metaClass);
}
replaceCallSite(callSite, site);
return site;
}
use of groovy.lang.MetaClassImpl in project groovy by apache.
the class AbstractCallSite method createPogoMetaClassGetPropertySite.
private CallSite createPogoMetaClassGetPropertySite(final GroovyObject receiver) {
MetaClass metaClass = receiver.getMetaClass();
CallSite site;
if (metaClass.getClass() != MetaClassImpl.class || GroovyCategorySupport.hasCategoryInCurrentThread()) {
site = new PogoMetaClassGetPropertySite(this, metaClass);
} else {
final MetaProperty effective = ((MetaClassImpl) metaClass).getEffectiveGetMetaProperty(this.array.owner, receiver, name, false);
if (effective != null) {
if (effective instanceof CachedField)
site = new GetEffectivePogoFieldSite(this, metaClass, (CachedField) effective);
else
site = new GetEffectivePogoPropertySite(this, metaClass, effective);
} else {
site = new PogoMetaClassGetPropertySite(this, metaClass);
}
}
array.array[index] = site;
return site;
}
use of groovy.lang.MetaClassImpl in project groovy by apache.
the class CallSiteArray method createCallConstructorSite.
private static CallSite createCallConstructorSite(CallSite callSite, Class receiver, Object[] args) {
MetaClass metaClass = InvokerHelper.getMetaClass(receiver);
CallSite site = metaClass instanceof MetaClassImpl ? ((MetaClassImpl) metaClass).createConstructorSite(callSite, args) : new MetaClassConstructorSite(callSite, metaClass);
replaceCallSite(callSite, site);
return site;
}
Aggregations