/** * Get the number of parameters of the method. * * @return The number of method parameters, i.e. {@code getParameterInfo().size()}. */ public int getNumParameters() { // return getTypeSignature().getParameterTypeSignatures().size(); return getParameterInfo().length; }
/** * Returns the parameter type signatures for the method. If the method has no parameters, returns a zero-sized * array. * * Note that it is always faster to call {@link #getParameterInfo()} and get the parameter information from the * returned list of {@link MethodParameterInfo} objects, since this method calls that to compile its results. * * @return The method parameter types, as an array of parsed type signatures. */ public TypeSignature[] getParameterTypeSignatures() { final MethodParameterInfo[] parameterInfo = getParameterInfo(); final TypeSignature[] paramTypeSignaturesOrTypeDescriptors = new TypeSignature[parameterInfo.length]; for (int i = 0; i < parameterInfo.length; i++) { final MethodParameterInfo paramInfo = parameterInfo[i]; final TypeSignature typeSig = paramInfo.getTypeSignature(); paramTypeSignaturesOrTypeDescriptors[i] = typeSig == null ? paramInfo.getTypeDescriptor() : typeSig; } return paramTypeSignaturesOrTypeDescriptors; }
final MethodParameterInfo[] parameterInfo = getParameterInfo(); boolean hasAnnotations = false; for (int i = 0; i < parameterInfo.length; i++) {
/** * Returns the parameter types for the method. If the method has no parameters, returns a zero-sized array. * * Note that it is always faster to call {@link #getParameterInfo()} and get the parameter information from the * returned list of {@link MethodParameterInfo} objects, since this method calls that to compile its results. * * <p> * Note that this calls Class.forName() on the parameter types, which will cause the class to be loaded, and * possibly initialized. If the class is initialized, this can trigger side effects. * * @return The list of {@code Class<?>} references for the method parameter types. * @throws IllegalArgumentException * if the parameter types of the method could not be loaded. */ public Class<?>[] getParameterTypes() throws IllegalArgumentException { // Can't instantiate type signatures, since they may have type variables. // Therefore, we use type descriptors, which are the result of type erasure. final MethodParameterInfo[] parameterInfo = getParameterInfo(); final TypeSignature[] paramTypeDescriptors = new TypeSignature[parameterInfo.length]; for (int i = 0; i < parameterInfo.length; i++) { final MethodParameterInfo paramInfo = parameterInfo[i]; final TypeSignature typeDesc = paramInfo.getTypeDescriptor(); paramTypeDescriptors[i] = typeDesc; } return toClassRefs(paramTypeDescriptors, scanResult); }
/** * Returns the method parameter names, if available (only available in classfiles compiled in JDK8 or above * using the -parameters commandline switch), otherwise returns null if the parameter names are not known. Note * that even when a non-null String array is returned, one or more individual array elements may be null, * representing unnamed parameters. * * Note that it is always faster to call {@link #getParameterInfo()} and get the parameter information from the * returned list of {@link MethodParameterInfo} objects, since this method calls that to compile its results. * * @return The method parameter names, as an array of Strings, or null if parameter names are not available. */ public String[] getParameterNames() { final MethodParameterInfo[] parameterInfo = getParameterInfo(); boolean hasNames = false; for (int i = 0; i < parameterInfo.length; i++) { if (parameterInfo[i].getName() != null) { hasNames = true; break; } } if (!hasNames) { // No name info return null; } final String[] paramNames = new String[parameterInfo.length]; for (int i = 0; i < parameterInfo.length; i++) { paramNames[i] = parameterInfo[i].getName(); } return paramNames; }
final MethodParameterInfo[] parameterInfo = getParameterInfo(); boolean hasNames = false; for (int i = 0; i < parameterInfo.length; i++) {
final MethodParameterInfo[] allParamInfo = getParameterInfo(); boolean hasParamNames = false; for (int i = 0, numParams = allParamInfo.length; i < numParams; i++) {
buf.append('('); if (mi.getNumParameters() != 0) { final MethodParameterInfo[] paramInfo = mi.getParameterInfo(); for (int i = 0, wrapPos = 0; i < paramInfo.length; i++) { if (i > 0) {