public Class getReturnType() { return method.getReturnType(); }
public CachedMethod searchMethods(String name, CachedClass[] parameterTypes) { CachedMethod[] methods = getMethods(); CachedMethod res = null; for (CachedMethod m : methods) { if (m.getName().equals(name) && ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes()) && (res == null || res.getReturnType().isAssignableFrom(m.getReturnType()))) res = m; } return res; }
private int compareToMethod(Method other) { if (other == null) return -1; final int strComp = getName().compareTo(other.getName()); if (strComp != 0) return strComp; final int retComp = getReturnType().getName().compareTo(other.getReturnType().getName()); if (retComp != 0) return retComp; CachedClass[] params = getParameterTypes(); Class[] mparams = other.getParameterTypes(); final int pd = params.length - mparams.length; if (pd != 0) return pd; for (int i = 0; i != params.length; ++i) { final int nameComp = params[i].getName().compareTo(mparams[i].getName()); if (nameComp != 0) return nameComp; } return 0; }
public String getDescriptor() { return BytecodeHelper.getMethodDescriptor(getReturnType(), getNativeParameterTypes()); }
private int compareToCachedMethod(CachedMethod other) { if (other == null) return -1; final int strComp = getName().compareTo(other.getName()); if (strComp != 0) return strComp; final int retComp = getReturnType().getName().compareTo(other.getReturnType().getName()); if (retComp != 0) return retComp; CachedClass[] params = getParameterTypes(); CachedClass[] otherParams = other.getParameterTypes(); final int pd = params.length - otherParams.length; if (pd != 0) return pd; for (int i = 0; i != params.length; ++i) { final int nameComp = params[i].getName().compareTo(otherParams[i].getName()); if (nameComp != 0) return nameComp; } final int classComp = cachedClass.toString().compareTo(other.getDeclaringClass().toString()); if (classComp != 0) return classComp; throw new RuntimeException("Should never happen"); }
continue; final Class returnType = method.getReturnType(); record.returnType = method.getReturnType(); record.parameters = method.getNativeParameterTypes(); record.className = className;
/** * @return the matching method which should be found */ private MetaMethod findMethod(CachedMethod aMethod) { Object methods = getMethods(theClass, aMethod.getName(), false); if (methods instanceof FastArray) { FastArray m = (FastArray) methods; final int len = m.size; final Object data[] = m.getArray(); for (int i = 0; i != len; ++i) { MetaMethod method = (MetaMethod) data[i]; if (method.isMethod(aMethod)) { return method; } } } else { MetaMethod method = (MetaMethod) methods; if (method.getName().equals(aMethod.getName()) // TODO: should be better check for case when only diff in modifiers can be SYNTHETIC flag // && method.getModifiers() == aMethod.getModifiers() && method.getReturnType().equals(aMethod.getReturnType()) && MetaMethod.equal(method.getParameterTypes(), aMethod.getParameterTypes())) { return method; } } return aMethod; }
String descriptor = BytecodeHelper.getMethodDescriptor(cachedMethod.getReturnType(), cachedMethod.getNativeParameterTypes()); BytecodeHelper.box(mv, cachedMethod.getReturnType()); if (cachedMethod.getReturnType() == void.class) { mv.visitInsn(Opcodes.ACONST_NULL);
private static void createInvokeMethod(CachedMethod method, ClassWriter cw, Class returnType, String methodDescriptor) { MethodVisitor mv; mv = cw.visitMethod(ACC_PUBLIC, "invoke", "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 1); BytecodeHelper.doCast(mv, method.getParameterTypes()[0].getTheClass()); loadParameters(method, 2, mv); mv.visitMethodInsn(INVOKESTATIC, BytecodeHelper.getClassInternalName(method.getDeclaringClass().getTheClass()), method.getName(), methodDescriptor, false); BytecodeHelper.box(mv, returnType); if (method.getReturnType() == void.class) { mv.visitInsn(ACONST_NULL); } mv.visitInsn(ARETURN); mv.visitMaxs(0, 0); mv.visitEnd(); }
if (method.getReturnType() == void.class) { mv.visitInsn(ACONST_NULL);
public Class getReturnType() { return method.getReturnType(); }
public Class getReturnType() { return method.getReturnType(); }
public Class getReturnType() { return method.getReturnType(); }
public CachedMethod searchMethods(String name, CachedClass[] parameterTypes) { CachedMethod[] methods = getMethods(); CachedMethod res = null; for (CachedMethod m : methods) { if (m.getName().equals(name) && ReflectionCache.arrayContentsEq(parameterTypes, m.getParameterTypes()) && (res == null || res.getReturnType().isAssignableFrom(m.getReturnType()))) res = m; } return res; }
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 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 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 String getDescriptor() { return BytecodeHelper.getMethodDescriptor(getReturnType(), getNativeParameterTypes()); }
public String getDescriptor() { return BytecodeHelper.getMethodDescriptor(getReturnType(), getNativeParameterTypes()); }
public String getDescriptor() { return BytecodeHelper.getMethodDescriptor(getReturnType(), getNativeParameterTypes()); }