/** * Returns a string representation of the object. */ public String toString() { return getName() + " " + getDescriptor(); }
protected void extendToString(StringBuffer buffer) { buffer.append(' '); buffer.append(getName()); buffer.append(' '); buffer.append(methodInfo.getDescriptor()); }
public int compare(Object o1, Object o2) { CtConstructor c1 = (CtConstructor)o1; CtConstructor c2 = (CtConstructor)o2; return c1.getMethodInfo2().getDescriptor().compareTo( c2.getMethodInfo2().getDescriptor()); } });
/** * Sets a method descriptor. * * @see Descriptor */ public void setDescriptor(String desc) { if (!desc.equals(getDescriptor())) descriptor = constPool.addUtf8Info(desc); }
public String getReturnTypeName(final MethodInfo method) { String descriptor = method.getDescriptor(); descriptor = descriptor.substring(descriptor.lastIndexOf(")") + 1); return splitDescriptorToTypeNames(descriptor).get(0); }
public List<String> getParameterNames(final MethodInfo method) { String descriptor = method.getDescriptor(); descriptor = descriptor.substring(descriptor.indexOf("(") + 1, descriptor.lastIndexOf(")")); return splitDescriptorToTypeNames(descriptor); }
public int compare(Object o1, Object o2) { CtMethod m1 = (CtMethod)o1; CtMethod m2 = (CtMethod)o2; int value = m1.getName().compareTo(m2.getName()); if (value == 0) value = m1.getMethodInfo2().getDescriptor() .compareTo(m2.getMethodInfo2().getDescriptor()); return value; } });
/** * Obtains the type of the returned value. */ CtClass getReturnType0() throws NotFoundException { return Descriptor.getReturnType(methodInfo.getDescriptor(), declaringClass.getClassPool()); }
final String getStringRep() { if (cachedStringRep == null) cachedStringRep = methodInfo.getName() + Descriptor.getParamDescriptor(methodInfo.getDescriptor()); return cachedStringRep; }
public TransformBefore(Transformer next, CtMethod origMethod, CtMethod beforeMethod) throws NotFoundException { super(next, origMethod, beforeMethod); // override methodDescriptor = origMethod.getMethodInfo2().getDescriptor(); parameterTypes = origMethod.getParameterTypes(); locals = 0; maxLocals = 0; saveCode = loadCode = null; }
/** * Obtains parameter types of this method/constructor. */ public CtClass[] getParameterTypes() throws NotFoundException { return Descriptor.getParameterTypes(methodInfo.getDescriptor(), declaringClass.getClassPool()); }
private void testExistingMethod(MethodInfo newMinfo) throws DuplicateMemberException { String name = newMinfo.getName(); String descriptor = newMinfo.getDescriptor(); ListIterator it = methods.listIterator(0); while (it.hasNext()) if (isDuplicated(newMinfo, name, descriptor, (MethodInfo)it.next(), it)) throw new DuplicateMemberException("duplicate method: " + name + " in " + this.getName()); }
private static void checkSignature(CtMethod wrappedBody, String descriptor) throws CannotCompileException { if (!descriptor.equals(wrappedBody.getMethodInfo2().getDescriptor())) throw new CannotCompileException( "wrapped method with a bad signature: " + wrappedBody.getDeclaringClass().getName() + '.' + wrappedBody.getName()); }
public TransformCall(Transformer next, String oldMethodName, CtMethod substMethod) { super(next); methodname = oldMethodName; methodDescriptor = substMethod.getMethodInfo2().getDescriptor(); classname = newClassname = substMethod.getDeclaringClass().getName(); newMethodname = substMethod.getName(); constPool = null; newMethodIsPrivate = Modifier.isPrivate(substMethod.getModifiers()); }
public MapMaker(ClassPool classes, MethodInfo minfo, CodeAttribute ca) { super(classes, minfo.getConstPool(), ca.getMaxStack(), ca.getMaxLocals(), TypedBlock.getRetType(minfo.getDescriptor())); }
/** * Copies all constant pool items to a given new constant pool * and replaces the original items with the new ones. * This is used for garbage collecting the items of removed fields * and methods. * * @param cp the destination */ void compact(ConstPool cp) { name = cp.addUtf8Info(getName()); descriptor = cp.addUtf8Info(getDescriptor()); attribute = AttributeInfo.copyAll(attribute, cp); constPool = cp; }
public CtConstructor getConstructor(String desc) throws NotFoundException { CtMember.Cache memCache = getMembers(); CtMember cons = memCache.consHead(); CtMember consTail = memCache.lastCons(); while (cons != consTail) { cons = cons.next(); CtConstructor cc = (CtConstructor)cons; if (cc.getMethodInfo2().getDescriptor().equals(desc) && cc.isConstructor()) return cc; } return super.getConstructor(desc); }
public CtMethod getDeclaredMethod(String name, CtClass[] params) throws NotFoundException { String desc = Descriptor.ofParameters(params); CtMember.Cache memCache = getMembers(); CtMember mth = memCache.methodHead(); CtMember mthTail = memCache.lastMethod(); while (mth != mthTail) { mth = mth.next(); if (mth.getName().equals(name) && ((CtMethod)mth).getMethodInfo2().getDescriptor().startsWith(desc)) return (CtMethod)mth; } throw new NotFoundException(name + "(..) is not found in " + getName()); }
/** * Inserts a new parameter, which becomes the first parameter. */ public void insertParameter(CtClass type) throws CannotCompileException { declaringClass.checkModify(); String desc = methodInfo.getDescriptor(); String desc2 = Descriptor.insertParameter(type, desc); try { addParameter2(Modifier.isStatic(getModifiers()) ? 0 : 1, type, desc); } catch (BadBytecode e) { throw new CannotCompileException(e); } methodInfo.setDescriptor(desc2); }
/** * Appends a new parameter, which becomes the last parameter. */ public void addParameter(CtClass type) throws CannotCompileException { declaringClass.checkModify(); String desc = methodInfo.getDescriptor(); String desc2 = Descriptor.appendParameter(type, desc); int offset = Modifier.isStatic(getModifiers()) ? 0 : 1; try { addParameter2(offset + Descriptor.paramSize(desc), type, desc); } catch (BadBytecode e) { throw new CannotCompileException(e); } methodInfo.setDescriptor(desc2); }