private static String prependParameterToMethodDescriptor(String methodDescriptor, String type) { StringBuilder methodDescBuilder = new StringBuilder(); methodDescBuilder.append('('); methodDescBuilder.append(type); InternalTypeEnumeration typeEnumeration = new InternalTypeEnumeration(methodDescriptor); while (typeEnumeration.hasMoreTypes()) { methodDescBuilder.append(typeEnumeration.nextType()); } methodDescBuilder.append(')'); methodDescBuilder.append(typeEnumeration.returnType()); return methodDescBuilder.toString(); }
InternalTypeEnumeration enumeration = new InternalTypeEnumeration(descriptor); if (enumeration.hasFormalTypeParameters()) System.out.println(" Formal type parameters ["+enumeration.formalTypeParameters()+"]"); while (enumeration.hasMoreTypes()) System.out.println(" Type ["+enumeration.nextType()+"]"); if (enumeration.isMethodSignature()) System.out.println(" Return type ["+enumeration.returnType()+"]");
/** * Returns the next type from the method descriptor. */ public String nextType() { int startIndex = index; skipArray(); char c = descriptor.charAt(index++); switch (c) { case ClassConstants.INTERNAL_TYPE_CLASS_START: case ClassConstants.INTERNAL_TYPE_GENERIC_VARIABLE_START: { skipClass(); break; } case ClassConstants.INTERNAL_TYPE_GENERIC_START: { skipGeneric(); break; } } return descriptor.substring(startIndex, index); }
/** * Returns the number of parameters of the given internal method descriptor. * @param internalMethodDescriptor the internal method descriptor, * e.g. "<code>(ID)Z</code>". * @return the number of parameters, * e.g. 2. */ public static int internalMethodParameterCount(String internalMethodDescriptor) { InternalTypeEnumeration internalTypeEnumeration = new InternalTypeEnumeration(internalMethodDescriptor); int counter = 0; while (internalTypeEnumeration.hasMoreTypes()) { internalTypeEnumeration.nextType(); counter++; } return counter; }
new InternalTypeEnumeration(signatureAttribute.getSignature(clazz)); if (internalTypeEnumeration.hasFormalTypeParameters()) String type = internalTypeEnumeration.formalTypeParameters(); if (internalTypeEnumeration.hasMoreTypes()) String type = internalTypeEnumeration.nextType(); while (internalTypeEnumeration.hasMoreTypes()) String type = internalTypeEnumeration.nextType();
new InternalTypeEnumeration(descriptor); String parameterType = internalTypeEnumeration.nextType(); parameterTypes[parameterIndex] = parameterType; if (ClassUtil.internalTypeSize(parameterType) == 2)
InternalTypeEnumeration invokedTypeEnumeration) while (typeEnumeration.hasMoreTypes()) String type = typeEnumeration.nextType(); String invokedType = invokedTypeEnumeration != null ? invokedTypeEnumeration.nextType() : null; String methodReturnType = typeEnumeration.returnType(); convertToTargetType(invokedTypeEnumeration.returnType(), methodReturnType, composer);
private void skipClass() { while (true) { char c = descriptor.charAt(index++); switch (c) { case ClassConstants.INTERNAL_TYPE_GENERIC_START: skipGeneric(); break; case ClassConstants.INTERNAL_TYPE_CLASS_END: return; } } }
new InternalTypeEnumeration(accessorMethodDescriptor);
/** * Returns the size taken up on the stack by the parameters of the given * internal method descriptor. This accounts for long and double parameters * taking up two spaces, and a non-static method taking up an additional * entry. * @param internalMethodDescriptor the internal method descriptor, * e.g. "<code>(ID)Z</code>". * @param isStatic specifies whether the method is static, * e.g. false. * @return the size taken up on the stack, * e.g. 4. */ public static int internalMethodParameterSize(String internalMethodDescriptor, boolean isStatic) { InternalTypeEnumeration internalTypeEnumeration = new InternalTypeEnumeration(internalMethodDescriptor); int size = isStatic ? 0 : 1; while (internalTypeEnumeration.hasMoreTypes()) { String internalType = internalTypeEnumeration.nextType(); size += internalTypeSize(internalType); } return size; }
new InternalTypeEnumeration(signatureAttribute.getSignature(clazz)); if (internalTypeEnumeration.hasFormalTypeParameters()) String type = internalTypeEnumeration.formalTypeParameters(); if (internalTypeEnumeration.hasMoreTypes()) String type = internalTypeEnumeration.nextType(); while (internalTypeEnumeration.hasMoreTypes()) String type = internalTypeEnumeration.nextType();
new InternalTypeEnumeration(descriptor); String parameterType = internalTypeEnumeration.nextType(); parameterTypes[parameterIndex] = parameterType; if (ClassUtil.internalTypeSize(parameterType) == 2)
InternalTypeEnumeration invokedTypeEnumeration) while (typeEnumeration.hasMoreTypes()) String type = typeEnumeration.nextType(); String invokedType = invokedTypeEnumeration != null ? invokedTypeEnumeration.nextType() : null; String methodReturnType = typeEnumeration.returnType(); convertToTargetType(invokedTypeEnumeration.returnType(), methodReturnType, composer);
private void skipClass() { while (true) { char c = descriptor.charAt(index++); switch (c) { case ClassConstants.TYPE_GENERIC_START: skipGeneric(); break; case ClassConstants.TYPE_CLASS_END: return; } } }
new InternalTypeEnumeration(accessorMethodDescriptor);
/** * Checks the classes mentioned in the given class member descriptor, * printing notes if necessary. */ private void checkDescriptor(String descriptor) { if (descriptor != null) { InternalTypeEnumeration internalTypeEnumeration = new InternalTypeEnumeration(descriptor); checkType(internalTypeEnumeration.returnType()); while (internalTypeEnumeration.hasMoreTypes()) { checkType(internalTypeEnumeration.nextType()); } } }
InternalTypeEnumeration enumeration = new InternalTypeEnumeration(descriptor); if (enumeration.hasFormalTypeParameters()) System.out.println(" Formal type parameters ["+enumeration.formalTypeParameters()+"]"); while (enumeration.hasMoreTypes()) System.out.println(" Type ["+enumeration.nextType()+"]"); if (enumeration.isMethodSignature()) System.out.println(" Return type ["+enumeration.returnType()+"]");
/** * Converts an internal method descriptor into an external method argument * description. * @param internalMethodDescriptor the internal method descriptor, * e.g. "<code>(II)Z</code>". * @return the external method argument description, * e.g. "<code>int,int</code>". */ public static String externalMethodArguments(String internalMethodDescriptor) { StringBuffer externalMethodNameAndArguments = new StringBuffer(); InternalTypeEnumeration internalTypeEnumeration = new InternalTypeEnumeration(internalMethodDescriptor); while (internalTypeEnumeration.hasMoreTypes()) { externalMethodNameAndArguments.append(externalType(internalTypeEnumeration.nextType())); if (internalTypeEnumeration.hasMoreTypes()) { externalMethodNameAndArguments.append(JavaConstants.METHOD_ARGUMENTS_SEPARATOR); } } return externalMethodNameAndArguments.toString(); }
new InternalTypeEnumeration(signatureAttribute.getSignature(clazz)); if (internalTypeEnumeration.hasFormalTypeParameters()) String type = internalTypeEnumeration.formalTypeParameters(); if (internalTypeEnumeration.hasMoreTypes()) String type = internalTypeEnumeration.nextType(); while (internalTypeEnumeration.hasMoreTypes()) String type = internalTypeEnumeration.nextType();
new InternalTypeEnumeration(descriptor); String parameterType = internalTypeEnumeration.nextType(); parameterTypes[parameterIndex] = parameterType; if (ClassUtil.internalTypeSize(parameterType) == 2)