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 createCallConstructorSite.
private static CallSite createCallConstructorSite(CallSite callSite, Class receiver, Object[] args) {
MetaClass metaClass = InvokerHelper.getMetaClass(receiver);
CallSite site;
if (metaClass instanceof MetaClassImpl) {
site = ((MetaClassImpl) metaClass).createConstructorSite(callSite, args);
} else
site = new MetaClassConstructorSite(callSite, metaClass);
replaceCallSite(callSite, site);
return site;
}
use of groovy.lang.MetaClassImpl in project groovy-core by groovy.
the class Selector method getMetaClassImpl.
/**
* Returns the MetaClassImpl if the given MetaClass is one of
* MetaClassImpl, AdaptingMetaClass or ClosureMetaClass. If
* none of these cases matches, this method returns null.
*/
private static MetaClassImpl getMetaClassImpl(MetaClass mc, boolean includeEMC) {
Class mcc = mc.getClass();
boolean valid = mcc == MetaClassImpl.class || mcc == AdaptingMetaClass.class || mcc == ClosureMetaClass.class || (includeEMC && mcc == ExpandoMetaClass.class);
if (!valid) {
if (LOG_ENABLED)
LOG.info("meta class is neither MetaClassImpl, nor AdoptingMetaClass, nor ClosureMetaClass, normal method selection path disabled.");
return null;
}
if (LOG_ENABLED)
LOG.info("meta class is a recognized MetaClassImpl");
return (MetaClassImpl) mc;
}
use of groovy.lang.MetaClassImpl in project groovy by apache.
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 Selector method getMetaClassImpl.
/**
* Returns the MetaClassImpl if the given MetaClass is one of
* MetaClassImpl, AdaptingMetaClass or ClosureMetaClass. If
* none of these cases matches, this method returns null.
*/
private static MetaClassImpl getMetaClassImpl(MetaClass mc, boolean includeEMC) {
Class mcc = mc.getClass();
boolean valid = mcc == MetaClassImpl.class || mcc == AdaptingMetaClass.class || mcc == ClosureMetaClass.class || (includeEMC && mcc == ExpandoMetaClass.class);
if (!valid) {
if (LOG_ENABLED)
LOG.info("meta class is neither MetaClassImpl, nor AdoptingMetaClass, nor ClosureMetaClass, normal method selection path disabled.");
return null;
}
if (LOG_ENABLED)
LOG.info("meta class is a recognized MetaClassImpl");
return (MetaClassImpl) mc;
}
Aggregations