| Method from org.codehaus.groovy.reflection.CachedClass Detail: |
public void addNewMopMethods(List arr) {
final MetaClass metaClass = classInfo.getStrongMetaClass();
if (metaClass != null) {
if (metaClass.getClass() == MetaClassImpl.class) {
classInfo.setStrongMetaClass(null);
updateAddNewMopMethods(arr);
classInfo.setStrongMetaClass(new MetaClassImpl(metaClass.getTheClass()));
return;
}
if (metaClass.getClass() == ExpandoMetaClass.class) {
ExpandoMetaClass emc = (ExpandoMetaClass)metaClass;
classInfo.setStrongMetaClass(null);
updateAddNewMopMethods(arr);
ExpandoMetaClass newEmc = new ExpandoMetaClass(metaClass.getTheClass());
for (Iterator it = emc.getExpandoMethods().iterator(); it.hasNext(); ) {
newEmc.registerInstanceMethod((MetaMethod) it.next());
}
newEmc.initialize();
classInfo.setStrongMetaClass(newEmc);
return;
}
throw new GroovyRuntimeException("Can't add methods to class " + getTheClass().getName() + ". Strong custom meta class already set.");
}
classInfo.setWeakMetaClass(null);
updateAddNewMopMethods(arr);
}
|
public void box(BytecodeHelper helper) {
helper.box(getTheClass());
}
|
public Object coerceArgument(Object argument) {
return argument;
}
|
public void doCast(BytecodeHelper helper) {
helper.doCast(getTheClass());
}
|
public CachedClass getCachedClass() {
return this;
}
|
public CachedClass getCachedSuperClass() {
return cachedSuperClass.get();
}
|
public CallSiteClassLoader getCallSiteLoader() {
return callSiteClassLoader.get();
}
|
public CachedConstructor[] getConstructors() {
return constructors.get();
}
|
public Set getDeclaredInterfaces() {
return declaredInterfaces.get();
}
|
public CachedField[] getFields() {
return fields.get();
}
|
public Collection getHierarchy() {
return hierarchy.get();
}
|
public Set getInterfaces() {
return interfaces.get();
}
|
public CachedMethod[] getMethods() {
return methods.get();
}
|
public int getModifiers() {
return modifiers;
}
|
public String getName() {
return getTheClass().getName();
}
|
public MetaMethod[] getNewMetaMethods() {
ArrayList< MetaMethod > arr = new ArrayList< MetaMethod >();
arr.addAll(Arrays.asList(classInfo.newMetaMethods));
final MetaClass metaClass = classInfo.getStrongMetaClass();
if (metaClass != null && metaClass instanceof ExpandoMetaClass) {
arr.addAll(((ExpandoMetaClass)metaClass).getExpandoMethods());
}
if (isInterface) {
MetaClass mc = ReflectionCache.OBJECT_CLASS.classInfo.getStrongMetaClass();
addSubclassExpandos(arr, mc);
}
else {
for (CachedClass cls = this; cls != null; cls = cls.getCachedSuperClass()) {
MetaClass mc = cls.classInfo.getStrongMetaClass();
addSubclassExpandos(arr, mc);
}
}
for (CachedClass inf : getInterfaces()) {
MetaClass mc = inf.classInfo.getStrongMetaClass();
addSubclassExpandos(arr, mc);
}
return arr.toArray(new MetaMethod[arr.size()]);
}
|
public int getSuperClassDistance() {
synchronized (getTheClass()) {
if (distance == -1) {
int distance = 0;
for (Class klazz= getTheClass(); klazz != null; klazz = klazz.getSuperclass()) {
distance++;
}
this.distance = distance;
}
return distance;
}
}
|
public final Class getTheClass() {
return cachedClass;
}
|
public String getTypeDescription() {
return BytecodeHelper.getTypeDescription(getTheClass());
}
|
public int hashCode() {
if (hashCode == 0) {
hashCode = super.hashCode();
if (hashCode == 0)
hashCode = 0xcafebebe;
}
return hashCode;
}
|
public boolean isAssignableFrom(Class argument) {
return argument == null || ReflectionCache.isAssignableFrom(getTheClass(), argument);
}
|
public boolean isDirectlyAssignable(Object argument) {
return ReflectionCache.isAssignableFrom(getTheClass(), argument.getClass());
}
|
public boolean isInterface() {
return isInterface;
}
|
public boolean isPrimitive() {
return isPrimitive;
}
|
public boolean isVoid() {
return getTheClass() == void.class;
}
|
public CachedMethod searchMethods(String name,
CachedClass[] parameterTypes) {
CachedMethod[] methods = getMethods();
CachedMethod res = null;
for (int i = 0; i < methods.length; i++) {
CachedMethod m = methods[i];
if (m.getName().equals(name)
&& ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes())
&& (res == null || res.getReturnType().isAssignableFrom(m.getReturnType())))
res = m;
}
return res;
}
|
public void setNewMopMethods(List arr) {
final MetaClass metaClass = classInfo.getStrongMetaClass();
if (metaClass != null) {
if (metaClass.getClass() == MetaClassImpl.class) {
classInfo.setStrongMetaClass(null);
updateSetNewMopMethods(arr);
classInfo.setStrongMetaClass(new MetaClassImpl(metaClass.getTheClass()));
return;
}
if (metaClass.getClass() == ExpandoMetaClass.class) {
classInfo.setStrongMetaClass(null);
updateSetNewMopMethods(arr);
ExpandoMetaClass newEmc = new ExpandoMetaClass(metaClass.getTheClass());
newEmc.initialize();
classInfo.setStrongMetaClass(newEmc);
return;
}
throw new GroovyRuntimeException("Can't add methods to class " + getTheClass().getName() + ". Strong custom meta class already set.");
}
classInfo.setWeakMetaClass(null);
updateSetNewMopMethods(arr);
}
|
public String toString() {
return cachedClass.toString();
}
|
public void unbox(BytecodeHelper helper) {
helper.unbox(getTheClass());
}
|