/** * Returns the descriptor representing a constructor receiving * the given parameter types. * * @param paramTypes parameter types */ public static String ofConstructor(CtClass[] paramTypes) { return ofMethod(CtClass.voidType, paramTypes); }
/** * Returns the descriptor representing a list of parameter types. * For example, if the given parameter types are two <code>int</code>, * then this method returns <code>"(II)"</code>. * * @param paramTypes parameter types */ public static String ofParameters(CtClass[] paramTypes) { return ofMethod(null, paramTypes); }
/** * Returns the descriptor representing a list of parameter types. * For example, if the given parameter types are two <code>int</code>, * then this method returns <code>"(II)"</code>. * * @param paramTypes parameter types */ public static String ofParameters(CtClass[] paramTypes) { return ofMethod(null, paramTypes); }
/** * Returns the descriptor representing a constructor receiving * the given parameter types. * * @param paramTypes parameter types */ public static String ofConstructor(CtClass[] paramTypes) { return ofMethod(CtClass.voidType, paramTypes); }
/** * Appends INVOKESTATIC. * * @param clazz the target class. * @param name the method name * @param returnType the return type. * @param paramTypes the parameter types. */ public void addInvokestatic(CtClass clazz, String name, CtClass returnType, CtClass[] paramTypes) { String desc = Descriptor.ofMethod(returnType, paramTypes); addInvokestatic(clazz, name, desc); }
/** * Appends INVOKESPECIAL. * * @param clazz the target class. * @param name the method name. * @param returnType the return type. * @param paramTypes the parameter types. */ public void addInvokespecial(CtClass clazz, String name, CtClass returnType, CtClass[] paramTypes) { String desc = Descriptor.ofMethod(returnType, paramTypes); addInvokespecial(clazz, name, desc); }
/** * Appends INVOKEINTERFACE. * * @param clazz the target class. * @param name the method name * @param returnType the return type. * @param paramTypes the parameter types. * @param count the count operand of the instruction. */ public void addInvokeinterface(CtClass clazz, String name, CtClass returnType, CtClass[] paramTypes, int count) { String desc = Descriptor.ofMethod(returnType, paramTypes); addInvokeinterface(clazz, name, desc, count); }
/** * Appends INVOKEVIRTUAL. * * <p>The specified method must not be an inherited method. * It must be directly declared in the class specified * in <code>clazz</code>. * * @param clazz the target class. * @param name the method name * @param returnType the return type. * @param paramTypes the parameter types. */ public void addInvokevirtual(CtClass clazz, String name, CtClass returnType, CtClass[] paramTypes) { String desc = Descriptor.ofMethod(returnType, paramTypes); addInvokevirtual(clazz, name, desc); }
/** * Appends INVOKESTATIC. * * @param clazz the target class. * @param name the method name * @param returnType the return type. * @param paramTypes the parameter types. */ public void addInvokestatic(CtClass clazz, String name, CtClass returnType, CtClass[] paramTypes) { String desc = Descriptor.ofMethod(returnType, paramTypes); addInvokestatic(clazz, name, desc); }
/** * Appends INVOKESPECIAL. * * @param clazz the target class. * @param name the method name. * @param returnType the return type. * @param paramTypes the parameter types. */ public void addInvokespecial(CtClass clazz, String name, CtClass returnType, CtClass[] paramTypes) { String desc = Descriptor.ofMethod(returnType, paramTypes); addInvokespecial(clazz, name, desc); }
/** * Appends INVOKEINTERFACE. * * @param clazz the target class. * @param name the method name * @param returnType the return type. * @param paramTypes the parameter types. * @param count the count operand of the instruction. */ public void addInvokeinterface(CtClass clazz, String name, CtClass returnType, CtClass[] paramTypes, int count) { String desc = Descriptor.ofMethod(returnType, paramTypes); addInvokeinterface(clazz, name, desc, count); }
/** * Appends INVOKEVIRTUAL. * * <p>The specified method must not be an inherited method. * It must be directly declared in the class specified * in <code>clazz</code>. * * @param clazz the target class. * @param name the method name * @param returnType the return type. * @param paramTypes the parameter types. */ public void addInvokevirtual(CtClass clazz, String name, CtClass returnType, CtClass[] paramTypes) { String desc = Descriptor.ofMethod(returnType, paramTypes); addInvokevirtual(clazz, name, desc); }
/** * Creates a public abstract method. The created method must be * added to a class with <code>CtClass.addMethod()</code>. * * @param declaring the class to which the created method is added. * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * * @see CtClass#addMethod(CtMethod) */ public CtMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass declaring) { this(null, declaring); ConstPool cp = declaring.getClassFile2().getConstPool(); String desc = Descriptor.ofMethod(returnType, parameters); methodInfo = new MethodInfo(cp, mname, desc); setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT); }
/** * Creates a public abstract method. The created method must be * added to a class with <code>CtClass.addMethod()</code>. * * @param declaring the class to which the created method is added. * @param returnType the type of the returned value * @param mname the method name * @param parameters a list of the parameter types * * @see CtClass#addMethod(CtMethod) */ public CtMethod(CtClass returnType, String mname, CtClass[] parameters, CtClass declaring) { this(null, declaring); ConstPool cp = declaring.getClassFile2().getConstPool(); String desc = Descriptor.ofMethod(returnType, parameters); methodInfo = new MethodInfo(cp, mname, desc); setModifiers(Modifier.PUBLIC | Modifier.ABSTRACT); }
bytecode.addLdc(Descriptor.ofMethod(returnType, paramTypeList)); bytecode.addInvokestatic("javassist/runtime/Desc", "getParams", "(Ljava/lang/String;)[Ljava/lang/Class;");
bytecode.addLdc(Descriptor.ofMethod(returnType, paramTypeList)); bytecode.addInvokestatic("javassist/runtime/Desc", "getParams", "(Ljava/lang/String;)[Ljava/lang/Class;");
args[0] = pt; code.addInvokespecial(wrapper, "<init>", Descriptor.ofMethod(CtClass.voidType, args));
args[0] = pt; code.addInvokespecial(wrapper, "<init>", Descriptor.ofMethod(CtClass.voidType, args));
/** * Returns the descriptor representing a list of parameter types. * For example, if the given parameter types are two <code>int</code>, * then this method returns <code>"(II)"</code>. * * @param paramTypes parameter types */ public static String ofParameters(CtClass[] paramTypes) { return ofMethod(null, paramTypes); }
/** * Returns the descriptor representing a constructor receiving * the given parameter types. * * @param paramTypes parameter types */ public static String ofConstructor(CtClass[] paramTypes) { return ofMethod(CtClass.voidType, paramTypes); }