org.jf.dexlib2.iface.MethodParameter Java Examples

The following examples show how to use org.jf.dexlib2.iface.MethodParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DexBackedMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends MethodParameter> getParameters() {
    int parametersOffset = getParametersOffset();
    if (parametersOffset > 0) {
        final List<String> parameterTypes = getParameterTypes();

        return new AbstractForwardSequentialList<MethodParameter>() {
            @Nonnull @Override public Iterator<MethodParameter> iterator() {
                return new ParameterIterator(parameterTypes,
                        getParameterAnnotations(),
                        getParameterNames());
            }

            @Override public int size() {
                return parameterTypes.size();
            }
        };
    }
    return ImmutableList.of();
}
 
Example #2
Source File: ReflectionMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final java.lang.reflect.Method method = this.method;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #3
Source File: DexBuilder.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass,
                                           @Nonnull String name,
                                           @Nullable List<? extends MethodParameter> parameters,
                                           @Nonnull String returnType,
                                           int accessFlags,
                                           @Nonnull Set<? extends Annotation> annotations,
                                           @Nullable MethodImplementation methodImplementation) {
    if (parameters == null) {
        parameters = ImmutableList.of();
    }
    return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType),
            internMethodParameters(parameters),
            accessFlags,
            context.annotationSetPool.internAnnotationSet(annotations),
            methodImplementation);
}
 
Example #4
Source File: ReflectionConstructor.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final Constructor method = this.constructor;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #5
Source File: DexBackedMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends MethodParameter> getParameters() {
    int parametersOffset = getParametersOffset();
    if (parametersOffset > 0) {
        final List<String> parameterTypes = getParameterTypes();

        return new AbstractForwardSequentialList<MethodParameter>() {
            @Nonnull @Override public Iterator<MethodParameter> iterator() {
                return new ParameterIterator(parameterTypes,
                        getParameterAnnotations(),
                        getParameterNames());
            }

            @Override public int size() {
                return parameterTypes.size();
            }
        };
    }
    return ImmutableList.of();
}
 
Example #6
Source File: ParameterIterator.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override public MethodParameter next() {
    @Nonnull final String type = parameterTypes.next().toString();
    @Nonnull final Set<? extends Annotation> annotations;
    @Nullable final String name;

    if (parameterAnnotations.hasNext()) {
        annotations = parameterAnnotations.next();
    } else {
        annotations = ImmutableSet.of();
    }

    if (parameterNames.hasNext()) {
        name = parameterNames.next();
    } else {
        name = null;
    }

    return new BaseMethodParameter() {
        @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return annotations; }
        @Nullable @Override public String getName() { return name; }
        @Nonnull @Override public String getType() { return type; }
    };
}
 
Example #7
Source File: MethodImplReIClassDef.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
protected Iterable<? extends MethodParameter> reParameters(final List<? extends MethodParameter> paramters) {
    final List<ImmutableMethodParameter> list = new ArrayList<ImmutableMethodParameter>();
    for (MethodParameter methodParameter : paramters) {
        boolean isBasic = false;
        if (basicType.containsKey(methodParameter.getType())) {
            isBasic = true;
        }
        list.add(new ImmutableMethodParameter(
                isBasic ? methodParameter.getType() : DefineUtils.getDefineClassName(classProcessor.classProcess(DefineUtils.getDalvikClassName(methodParameter.getType())).className,methodParameter.getType().startsWith("[")),
                methodParameter.getAnnotations(), methodParameter.getName()));
    }
    return new Iterable<ImmutableMethodParameter>() {
        @Override
        public Iterator<ImmutableMethodParameter> iterator() {
            return list.iterator();

        }
    };
}
 
Example #8
Source File: DexBuilder.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass,
                                           @Nonnull String name,
                                           @Nullable List<? extends MethodParameter> parameters,
                                           @Nonnull String returnType,
                                           int accessFlags,
                                           @Nonnull Set<? extends Annotation> annotations,
                                           @Nullable MethodImplementation methodImplementation) {
    if (parameters == null) {
        parameters = ImmutableList.of();
    }
    return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType),
            internMethodParameters(parameters),
            accessFlags,
            context.annotationSetPool.internAnnotationSet(annotations),
            methodImplementation);
}
 
Example #9
Source File: ReflectionConstructor.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final Constructor method = this.constructor;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #10
Source File: ReflectionMethod.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final java.lang.reflect.Method method = this.method;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #11
Source File: DexBuilder.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass,
                                           @Nonnull String name,
                                           @Nullable List<? extends MethodParameter> parameters,
                                           @Nonnull String returnType,
                                           int accessFlags,
                                           @Nonnull Set<? extends Annotation> annotations,
                                           @Nullable MethodImplementation methodImplementation) {
    if (parameters == null) {
        parameters = ImmutableList.of();
    }
    return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType),
            internMethodParameters(parameters),
            accessFlags,
            context.annotationSetPool.internAnnotationSet(annotations),
            methodImplementation);
}
 
Example #12
Source File: ReflectionConstructor.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final Constructor method = this.constructor;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #13
Source File: ReflectionMethod.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final java.lang.reflect.Method method = this.method;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #14
Source File: DexBackedMethod.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends MethodParameter> getParameters() {
    int parametersOffset = getParametersOffset();
    if (parametersOffset > 0) {
        final List<String> parameterTypes = getParameterTypes();

        return new AbstractForwardSequentialList<MethodParameter>() {
            @Nonnull @Override public Iterator<MethodParameter> iterator() {
                return new ParameterIterator(parameterTypes,
                        getParameterAnnotations(),
                        getParameterNames());
            }

            @Override public int size() {
                return parameterTypes.size();
            }
        };
    }
    return ImmutableList.of();
}
 
Example #15
Source File: ParameterIterator.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Override public MethodParameter next() {
    @Nonnull final String type = parameterTypes.next().toString();
    @Nonnull final Set<? extends Annotation> annotations;
    @Nullable final String name;

    if (parameterAnnotations.hasNext()) {
        annotations = parameterAnnotations.next();
    } else {
        annotations = ImmutableSet.of();
    }

    if (parameterNames.hasNext()) {
        name = parameterNames.next();
    } else {
        name = null;
    }

    return new BaseMethodParameter() {
        @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return annotations; }
        @Nullable @Override public String getName() { return name; }
        @Nonnull @Override public String getType() { return type; }
    };
}
 
Example #16
Source File: DexBuilder.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass,
                                           @Nonnull String name,
                                           @Nullable List<? extends MethodParameter> parameters,
                                           @Nonnull String returnType,
                                           int accessFlags,
                                           @Nonnull Set<? extends Annotation> annotations,
                                           @Nullable MethodImplementation methodImplementation) {
    if (parameters == null) {
        parameters = ImmutableList.of();
    }
    return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType),
            internMethodParameters(parameters),
            accessFlags,
            context.annotationSetPool.internAnnotationSet(annotations),
            methodImplementation);
}
 
Example #17
Source File: ReflectionConstructor.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final Constructor method = this.constructor;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #18
Source File: ReflectionMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public List<? extends MethodParameter> getParameters() {
    final java.lang.reflect.Method method = this.method;
    return new AbstractList<MethodParameter>() {
        private final Class[] parameters = method.getParameterTypes();

        @Override public MethodParameter get(final int index) {
            return new BaseMethodParameter() {
                @Nonnull @Override public Set<? extends Annotation> getAnnotations() {
                    return ImmutableSet.of();
                }

                @Nullable @Override public String getName() {
                    return null;
                }

                @Nonnull @Override public String getType() {
                    return ReflectionUtils.javaToDexName(parameters[index].getName());
                }
            };
        }

        @Override public int size() {
            return parameters.length;
        }
    };
}
 
Example #19
Source File: DexBackedMethod.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends MethodParameter> getParameters() {
    int parametersOffset = getParametersOffset();
    if (parametersOffset > 0) {
        final List<String> parameterTypes = getParameterTypes();

        return new AbstractForwardSequentialList<MethodParameter>() {
            @Nonnull @Override public Iterator<MethodParameter> iterator() {
                return new ParameterIterator(parameterTypes,
                        getParameterAnnotations(),
                        getParameterNames());
            }

            @Override public int size() {
                return parameterTypes.size();
            }
        };
    }
    return ImmutableList.of();
}
 
Example #20
Source File: ParameterIterator.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Override public MethodParameter next() {
    @Nonnull final String type = parameterTypes.next().toString();
    @Nonnull final Set<? extends Annotation> annotations;
    @Nullable final String name;

    if (parameterAnnotations.hasNext()) {
        annotations = parameterAnnotations.next();
    } else {
        annotations = ImmutableSet.of();
    }

    if (parameterNames.hasNext()) {
        name = parameterNames.next();
    } else {
        name = null;
    }

    return new BaseMethodParameter() {
        @Nonnull @Override public Set<? extends Annotation> getAnnotations() { return annotations; }
        @Nullable @Override public String getName() { return name; }
        @Nonnull @Override public String getType() { return type; }
    };
}
 
Example #21
Source File: MethodRewriter.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Override @Nonnull public List<? extends MethodParameter> getParameters() {
    // We can't use the MethodReferenceRewriter to rewrite the parameters, because we would lose
    // parameter names and annotations. If a method rewrite involves changing parameters, it needs
    // to be handled here as well as in the MethodReferenceRewriter

    return RewriterUtils.rewriteList(rewriters.getMethodParameterRewriter(), method.getParameters());
}
 
Example #22
Source File: ReflectionConstructor.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Nonnull @Override public List<String> getParameterTypes() {
    return new AbstractList<String>() {
        private final List<? extends MethodParameter> parameters = getParameters();

        @Override public String get(int index) {
            return parameters.get(index).getType();
        }

        @Override public int size() {
            return parameters.size();
        }
    };
}
 
Example #23
Source File: MethodRewriter.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Override @Nonnull public List<? extends MethodParameter> getParameters() {
    // We can't use the MethodReferenceRewriter to rewrite the parameters, because we would lose
    // parameter names and annotations. If a method rewrite involves changing parameters, it needs
    // to be handled here as well as in the MethodReferenceRewriter

    return RewriterUtils.rewriteList(rewriters.getMethodParameterRewriter(), method.getParameters());
}
 
Example #24
Source File: DexBuilder.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Nonnull private List<BuilderMethodParameter> internMethodParameters(
        @Nullable List<? extends MethodParameter> methodParameters) {
    if (methodParameters == null) {
        return ImmutableList.of();
    }
    return ImmutableList.copyOf(Iterators.transform(methodParameters.iterator(),
            new Function<MethodParameter, BuilderMethodParameter>() {
                @Nullable @Override public BuilderMethodParameter apply(MethodParameter input) {
                    return internMethodParameter(input);
                }
            }));
}
 
Example #25
Source File: ImmutableMethodParameter.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public static ImmutableMethodParameter of(MethodParameter methodParameter) {
    if (methodParameter instanceof ImmutableMethodParameter) {
        return (ImmutableMethodParameter)methodParameter;
    }
    return new ImmutableMethodParameter(
            methodParameter.getType(),
            methodParameter.getAnnotations(),
            methodParameter.getName());
}
 
Example #26
Source File: ImmutableMethod.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public ImmutableMethod(@Nonnull String definingClass,
                       @Nonnull String name,
                       @Nullable Iterable<? extends MethodParameter> parameters,
                       @Nonnull String returnType,
                       int accessFlags,
                       @Nullable Set<? extends Annotation> annotations,
                       @Nullable MethodImplementation methodImplementation) {
    this.definingClass = definingClass;
    this.name = name;
    this.parameters = ImmutableMethodParameter.immutableListOf(parameters);
    this.returnType = returnType;
    this.accessFlags = accessFlags;
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
    this.methodImplementation = ImmutableMethodImplementation.of(methodImplementation);
}
 
Example #27
Source File: ImmutableMethod.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public ImmutableMethod(@Nonnull String definingClass,
                       @Nonnull String name,
                       @Nullable Iterable<? extends MethodParameter> parameters,
                       @Nonnull String returnType,
                       int accessFlags,
                       @Nullable Set<? extends Annotation> annotations,
                       @Nullable MethodImplementation methodImplementation) {
    this.definingClass = definingClass;
    this.name = name;
    this.parameters = ImmutableMethodParameter.immutableListOf(parameters);
    this.returnType = returnType;
    this.accessFlags = accessFlags;
    this.annotations = ImmutableAnnotation.immutableSetOf(annotations);
    this.methodImplementation = ImmutableMethodImplementation.of(methodImplementation);
}
 
Example #28
Source File: ReflectionMethod.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull @Override public List<String> getParameterTypes() {
    return new AbstractList<String>() {
        private final List<? extends MethodParameter> parameters = getParameters();

        @Override public String get(int index) {
            return parameters.get(index).getType();
        }

        @Override public int size() {
            return parameters.size();
        }
    };
}
 
Example #29
Source File: ReflectionMethod.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
@Nonnull @Override public List<String> getParameterTypes() {
    return new AbstractList<String>() {
        private final List<? extends MethodParameter> parameters = getParameters();

        @Override public String get(int index) {
            return parameters.get(index).getType();
        }

        @Override public int size() {
            return parameters.size();
        }
    };
}
 
Example #30
Source File: DexBuilder.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull private List<BuilderMethodParameter> internMethodParameters(
        @Nullable List<? extends MethodParameter> methodParameters) {
    if (methodParameters == null) {
        return ImmutableList.of();
    }
    return ImmutableList.copyOf(Iterators.transform(methodParameters.iterator(),
            new Function<MethodParameter, BuilderMethodParameter>() {
                @Nullable @Override public BuilderMethodParameter apply(MethodParameter input) {
                    return internMethodParameter(input);
                }
            }));
}