本文整理匯總了Java中groovy.lang.GroovyObject.getClass方法的典型用法代碼示例。如果您正苦於以下問題:Java GroovyObject.getClass方法的具體用法?Java GroovyObject.getClass怎麽用?Java GroovyObject.getClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類groovy.lang.GroovyObject
的用法示例。
在下文中一共展示了GroovyObject.getClass方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: callCurrent
import groovy.lang.GroovyObject; //導入方法依賴的package包/類
public final Object callCurrent(GroovyObject receiver, Object[] args) throws Throwable {
if (checkCall(receiver)) {
try {
try {
return metaClass.invokeMethod(array.owner, receiver, name, args, false, true);
} catch (MissingMethodException e) {
if (e instanceof MissingMethodExecutionFailed) {
throw (MissingMethodException)e.getCause();
} else if (receiver.getClass() == e.getType() && e.getMethod().equals(name)) {
// in case there's nothing else, invoke the object's own invokeMethod()
return ((GroovyObject)receiver).invokeMethod(name, args);
} else {
throw e;
}
}
} catch (GroovyRuntimeException gre) {
throw ScriptBytecodeAdapter.unwrap(gre);
}
} else {
return CallSiteArray.defaultCallCurrent(this, receiver, args);
}
}
示例2: createCallCurrentSite
import groovy.lang.GroovyObject; //導入方法依賴的package包/類
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;
}
示例3: invokeMethodOnCurrentN
import groovy.lang.GroovyObject; //導入方法依賴的package包/類
public static Object invokeMethodOnCurrentN(Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments) throws Throwable {
Object result = null;
boolean intercepting = receiver instanceof GroovyInterceptable;
try {
try {
// if it's a pure interceptable object (even intercepting toString(), clone(), ...)
if (intercepting) {
result = receiver.invokeMethod(messageName, messageArguments);
}
//else if there's a statically typed method or a GDK method
else {
result = receiver.getMetaClass().invokeMethod(senderClass, receiver, messageName, messageArguments, false, true);
}
} catch (MissingMethodException e) {
if (e instanceof MissingMethodExecutionFailed) {
throw (MissingMethodException)e.getCause();
} else if (!intercepting && receiver.getClass() == e.getType() && e.getMethod().equals(messageName)) {
// in case there's nothing else, invoke the object's own invokeMethod()
result = receiver.invokeMethod(messageName, messageArguments);
} else {
throw e;
}
}
} catch (GroovyRuntimeException gre) {
throw unwrap(gre);
}
return result;
}
示例4: testCompile
import groovy.lang.GroovyObject; //導入方法依賴的package包/類
public void testCompile() throws Exception {
Class groovyClass = loader.parseClass(new File("src/test/org/codehaus/groovy/classgen/Main.groovy"));
System.out.println("Invoking main...");
GroovyObject object = (GroovyObject) groovyClass.newInstance();
assertTrue(object != null);
MetaClass metaClass = object.getMetaClass();
System.out.println("Metaclass: " + metaClass);
Class type = object.getClass();
System.out.println("Type: " + type);
// invoke via metaclass
metaClass.invokeMethod(object, "main", null);
// invoke directly
object.invokeMethod("main", null);
}