本文整理匯總了Java中org.codehaus.groovy.reflection.ReflectionCache.getCachedClass方法的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionCache.getCachedClass方法的具體用法?Java ReflectionCache.getCachedClass怎麽用?Java ReflectionCache.getCachedClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.codehaus.groovy.reflection.ReflectionCache
的用法示例。
在下文中一共展示了ReflectionCache.getCachedClass方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: MetaClassImpl
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
/**
* Constructor
*
* @param theClass The class this is the metaclass dor
* @param add The methods for this class
*/
public MetaClassImpl(final Class theClass, MetaMethod[] add) {
this.theClass = theClass;
theCachedClass = ReflectionCache.getCachedClass(theClass);
this.isGroovyObject = GroovyObject.class.isAssignableFrom(theClass);
this.isMap = Map.class.isAssignableFrom(theClass);
this.registry = GroovySystem.getMetaClassRegistry();
metaMethodIndex = new MetaMethodIndex(theCachedClass);
final MetaMethod[] metaMethods = theCachedClass.getNewMetaMethods();
if (add != null && !(add.length == 0)) {
List<MetaMethod> arr = new ArrayList<MetaMethod>();
arr.addAll(Arrays.asList(metaMethods));
arr.addAll(Arrays.asList(add));
myNewMetaMethods = arr.toArray(new MetaMethod[arr.size()]);
additionalMetaMethods = metaMethods;
}
else {
myNewMetaMethods = metaMethods;
additionalMetaMethods = EMPTY;
}
}
示例2: getMetaProperty
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
private MetaProperty getMetaProperty(Class _clazz, String name, boolean useSuper, boolean useStatic) {
if (_clazz == theClass)
return getMetaProperty(name, useStatic);
CachedClass clazz = ReflectionCache.getCachedClass(_clazz);
while (true) {
SingleKeyHashMap propertyMap;
if (useStatic) {
propertyMap = staticPropertyIndex;
} else if (useSuper) {
propertyMap = classPropertyIndexForSuper.getNullable(clazz);
} else {
propertyMap = classPropertyIndex.getNullable(clazz);
}
if (propertyMap == null) {
if (clazz != theCachedClass) {
clazz = theCachedClass;
continue;
} else {
return null;
}
}
return (MetaProperty) propertyMap.get(name);
}
}
示例3: createMetaMethods
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
private static void createMetaMethods(final Class extensionClass, final List<MetaMethod> metaMethods, final boolean isStatic) {
CachedClass cachedClass = ReflectionCache.getCachedClass(extensionClass);
CachedMethod[] methods = cachedClass.getMethods();
for (CachedMethod method : methods) {
if (method.isStatic() && method.isPublic() && method.getParamsCount() > 0) {
// an extension method is found
metaMethods.add(isStatic?new NewStaticMetaMethod(method) : new NewInstanceMetaMethod(method));
}
}
}
示例4: box
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
/**
* Generates the bytecode to autobox the current value on the stack
*/
@Deprecated
public static boolean box(MethodVisitor mv, Class type) {
if (ReflectionCache.getCachedClass(type).isPrimitive && type != void.class) {
String returnString = "(" + BytecodeHelper.getTypeDescription(type) + ")Ljava/lang/Object;";
mv.visitMethodInsn(INVOKESTATIC, DTT_CLASSNAME, "box", returnString, false);
return true;
}
return false;
}
示例5: use
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
private void use(Class categoryClass) {
CachedClass cachedClass = ReflectionCache.getCachedClass(categoryClass);
LinkedList<CachedClass> classStack = new LinkedList<CachedClass>();
for (CachedClass superClass = cachedClass; superClass.getTheClass()!=Object.class; superClass = superClass.getCachedSuperClass()) {
classStack.add(superClass);
}
while (!classStack.isEmpty()) {
CachedClass klazz = classStack.removeLast();
applyUse(klazz);
}
}
示例6: ClosureMetaMethod
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
public ClosureMetaMethod(String name, Class declaringClass, Closure c, CachedMethod doCall) {
super (doCall.getNativeParameterTypes());
this.name = name;
callable = c;
this.doCall = doCall;
this.declaringClass = ReflectionCache.getCachedClass(declaringClass);
}
示例7: Closure
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
public Closure(Object owner, Object thisObject) {
this.owner = owner;
this.delegate = owner;
this.thisObject = thisObject;
final CachedClosureClass cachedClass = (CachedClosureClass) ReflectionCache.getCachedClass(getClass());
parameterTypes = cachedClass.getParameterTypes();
maximumNumberOfParameters = cachedClass.getMaximumNumberOfParameters();
}
示例8: ClosureStaticMetaMethod
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
public ClosureStaticMetaMethod(String name, Class declaringClass, Closure c, Class[] paramTypes) {
super(paramTypes);
this.callable = c;
this.declaringClass = ReflectionCache.getCachedClass(declaringClass);
this.name = name;
}
示例9: getDeclaringClass
import org.codehaus.groovy.reflection.ReflectionCache; //導入方法依賴的package包/類
public CachedClass getDeclaringClass() {
return ReflectionCache.getCachedClass(declaringClass);
}