/** * Return the {@link Class} object for the return type of this method. * * @see BCMember#getDescriptor */ public Class getReturnType() { return Strings.toClass(getReturnName(), getClassLoader()); }
/** * Return the {@link Class} object for the return type of this method. * * @see BCMember#getDescriptor */ public Class getReturnType() { return Strings.toClass(getReturnName(), getClassLoader()); }
/** * Return the bytecode for the return type of this method. * * @see BCMember#getDescriptor */ public BCClass getReturnBC() { return getProject().loadClass(getReturnName(), getClassLoader()); }
/** * Return the bytecode for the return type of this method. * * @see BCMember#getDescriptor */ public BCClass getReturnBC() { return getProject().loadClass(getReturnName(), getClassLoader()); }
/** * Set the parameter types of this method. * * @see BCMember#setDescriptor */ public void setParams(String[] names) { if (names == null) names = new String[0]; setDescriptor(getProject().getNameCache().getDescriptor(getReturnName(), names)); }
/** * Set the parameter types of this method. * * @see BCMember#setDescriptor */ public void setParams(String[] names) { if (names == null) names = new String[0]; setDescriptor(getProject().getNameCache().getDescriptor(getReturnName(), names)); }
/** * Return the declared method with the given name and signature, * or null if none. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod getDeclaredMethod(String name, String returnType, String[] paramTypes) { if (paramTypes == null) paramTypes = new String[0]; BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(name) && methods[i].getReturnName().equals(_project.getNameCache(). getExternalForm(returnType, false)) && paramsMatch(methods[i], paramTypes)) return methods[i]; } return null; }
/** * Return the declared method with the given name and signature, * or null if none. * Note that in bytecode, constructors are named <code><init></code> * and static initializers are named <code><clinit></code>. */ public BCMethod getDeclaredMethod(String name, String returnType, String[] paramTypes) { if (paramTypes == null) paramTypes = new String[0]; BCMethod[] methods = getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(name) && methods[i].getReturnName().equals(_project.getNameCache(). getExternalForm(returnType, false)) && paramsMatch(methods[i], paramTypes)) return methods[i]; } return null; }
/** * Set the method this instruction operates on. * * @return this instruction, for method chaining */ public MethodInstruction setMethod(BCMethod method) { if (method == null) return setMethodIndex(0); return setMethod(method.getDeclarer().getName(), method.getName(), method.getReturnName(), method.getParamNames(), false); }
/** * Set the method this instruction operates on. * * @return this instruction, for method chaining */ public MethodInstruction setMethod(BCMethod method) { if (method == null) return setMethodIndex(0); return setMethod(method.getDeclarer().getName(), method.getName(), method.getReturnName(), method.getParamNames(), false); }
/** * Import the information in the given method as a new method of this class. * * @return the added method */ public BCMethod declareMethod(BCMethod method) { BCMethod newMethod = declareMethod(method.getName(), method.getReturnName(), method.getParamNames()); newMethod.setAccessFlags(method.getAccessFlags()); newMethod.setAttributes(method.getAttributes()); return newMethod; }
/** * Import the information in the given method as a new method of this class. * * @return the added method */ public BCMethod declareMethod(BCMethod method) { BCMethod newMethod = declareMethod(method.getName(), method.getReturnName(), method.getParamNames()); newMethod.setAccessFlags(method.getAccessFlags()); newMethod.setAttributes(method.getAttributes()); return newMethod; }
public void enterBCMethod(BCMethod obj) { openBlock("Method"); println("access=" + obj.getAccessFlags()); println("name=" + obj.getNameIndex() + " <" + obj.getName() + ">"); println("descriptor=" + obj.getDescriptorIndex()); println("return=" + obj.getReturnName()); String[] params = obj.getParamNames(); for (int i = 0; i < params.length; i++) println("param=" + params[i]); }
public void enterBCMethod(BCMethod obj) { openBlock("Method"); println("access=" + obj.getAccessFlags()); println("name=" + obj.getNameIndex() + " <" + obj.getName() + ">"); println("descriptor=" + obj.getDescriptorIndex()); println("return=" + obj.getReturnName()); String[] params = obj.getParamNames(); for (int i = 0; i < params.length; i++) println("param=" + params[i]); }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (isFieldAccess(fmd)) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (isFieldAccess(fmd)) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (_meta.getAccessType() == ClassMetaData.ACCESS_FIELD) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (isFieldAccess(fmd)) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }
/** * Create the generated setter {@link BCMethod} for <code>fmd</code>. The * calling environment will then populate this method's code block. */ private BCMethod createSetMethod(FieldMetaData fmd) { BCMethod setter; if (isFieldAccess(fmd)) { // static void pcSet<field> (XXX inst, <fieldtype> value) BCField field = _pc.getDeclaredField(fmd.getName()); setter = _pc.declareMethod(PRE + "Set" + fmd.getName(), void.class, new Class[]{ getType(_meta), fmd.getDeclaredType() }); setter.setAccessFlags(field.getAccessFlags() & ~Constants.ACCESS_TRANSIENT & ~Constants.ACCESS_VOLATILE); setter.setStatic(true); setter.setFinal(true); return setter; } // property access: // copy the user's getter method to a new name; we can't just reset // the name, because that will also reset all calls to the method setter = _pc.getDeclaredMethod(getSetterName(fmd), new Class[]{ fmd.getDeclaredType() }); BCMethod newsetter = _pc.declareMethod(PRE + setter.getName(), setter.getReturnName(), setter.getParamNames()); newsetter.setAccessFlags(setter.getAccessFlags()); newsetter.makeProtected(); transferCodeAttributes(setter, newsetter); return setter; }