/** * Add a constructor to this class. * * @param params May be null if constructor accepts no parameters. */ public MethodInfo addConstructor(Modifiers modifiers, TypeDesc[] params) { MethodDesc md = MethodDesc.forArguments(null, params); MethodInfo mi = new MethodInfo(this, modifiers, "<init>", md); mMethods.add(mi); return mi; }
/** * Add a method to this class. * * @param ret Is null if method returns void. * @param params May be null if method accepts no parameters. */ public MethodInfo addMethod(Modifiers modifiers, String methodName, TypeDesc ret, TypeDesc[] params) { MethodDesc md = MethodDesc.forArguments(ret, params); return addMethod(modifiers, methodName, md); }
public static MethodDesc forMethod(Method method) { Class[] paramClasses = method.getParameterTypes(); TypeDesc[] paramTypes; if (paramClasses == null || paramClasses.length == 0) { paramTypes = EMPTY_PARAMS; } else { paramTypes = new TypeDesc[paramClasses.length]; for (int i=paramClasses.length; --i>=0; ) { paramTypes[i] = TypeDesc.forClass(paramClasses[i]); } } return forArguments(TypeDesc.forClass(method.getReturnType()), paramTypes); }
/** * Add a static initializer to this class. */ public MethodInfo addInitializer() { MethodDesc md = MethodDesc.forArguments(null, null); Modifiers af = Modifiers.NONE.toStatic(true); MethodInfo mi = new MethodInfo(this, af, "<clinit>", md); mMethods.add(mi); return mi; }
/** * Get or create a constant from the constant pool representing a method * in any class. If the method returns void, set ret to null. */ public ConstantMethodInfo addConstantMethod(String className, String methodName, TypeDesc ret, TypeDesc[] params) { MethodDesc md = MethodDesc.forArguments(ret, params); ConstantInfo ci = new ConstantMethodInfo (addConstantClass(className), addConstantNameAndType(methodName, md)); return (ConstantMethodInfo)addConstant(ci); }
/** * Get or create a constant from the constant pool representing an * interface method in any interface. */ public ConstantInterfaceMethodInfo addConstantInterfaceMethod(String className, String methodName, TypeDesc ret, TypeDesc[] params) { MethodDesc md = MethodDesc.forArguments(ret, params); ConstantInfo ci = new ConstantInterfaceMethodInfo (addConstantClass(className), addConstantNameAndType(methodName, md)); return (ConstantInterfaceMethodInfo)addConstant(ci); }
/** * Add a constructor to this class. * * @param params May be null if constructor accepts no parameters. */ public MethodInfo addConstructor(Modifiers modifiers, TypeDesc[] params) { MethodDesc md = MethodDesc.forArguments(null, params); MethodInfo mi = new MethodInfo(this, modifiers, "<init>", md); mMethods.add(mi); return mi; }
/** * Add a method to this class. * * @param ret Is null if method returns void. * @param params May be null if method accepts no parameters. */ public MethodInfo addMethod(Modifiers modifiers, String methodName, TypeDesc ret, TypeDesc[] params) { MethodDesc md = MethodDesc.forArguments(ret, params); return addMethod(modifiers, methodName, md); }
public static MethodDesc forMethod(Method method) { Class[] paramClasses = method.getParameterTypes(); TypeDesc[] paramTypes; if (paramClasses == null || paramClasses.length == 0) { paramTypes = EMPTY_PARAMS; } else { paramTypes = new TypeDesc[paramClasses.length]; for (int i=paramClasses.length; --i>=0; ) { paramTypes[i] = TypeDesc.forClass(paramClasses[i]); } } return forArguments(TypeDesc.forClass(method.getReturnType()), paramTypes); }
/** * Add a static initializer to this class. */ public MethodInfo addInitializer() { MethodDesc md = MethodDesc.forArguments(null, null); Modifiers af = Modifiers.NONE.toStatic(true); MethodInfo mi = new MethodInfo(this, af, "<clinit>", md); mMethods.add(mi); return mi; }
/** * Get or create a constant from the constant pool representing an * interface method in any interface. */ public ConstantInterfaceMethodInfo addConstantInterfaceMethod(String className, String methodName, TypeDesc ret, TypeDesc[] params) { MethodDesc md = MethodDesc.forArguments(ret, params); ConstantInfo ci = new ConstantInterfaceMethodInfo (addConstantClass(className), addConstantNameAndType(methodName, md)); return (ConstantInterfaceMethodInfo)addConstant(ci); }
/** * Get or create a constant from the constant pool representing a method * in any class. If the method returns void, set ret to null. */ public ConstantMethodInfo addConstantMethod(String className, String methodName, TypeDesc ret, TypeDesc[] params) { MethodDesc md = MethodDesc.forArguments(ret, params); ConstantInfo ci = new ConstantMethodInfo (addConstantClass(className), addConstantNameAndType(methodName, md)); return (ConstantMethodInfo)addConstant(ci); }
paramDescs[i] = TypeDesc.forClass(params[i]); MethodDesc desc = MethodDesc.forArguments (TypeDesc.forClass(m.getReturnType()), paramDescs); key = m.getName() + ':' + desc;