Java Code Examples for org.jf.dexlib2.iface.reference.MethodReference#getParameterTypes()
The following examples show how to use
org.jf.dexlib2.iface.reference.MethodReference#getParameterTypes() .
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: ReferenceUtil.java From atlas with Apache License 2.0 | 6 votes |
public static String getMethodDescriptor(MethodReference methodReference, boolean useImplicitReference) { StringBuilder sb = new StringBuilder(); if (!useImplicitReference) { String clazz = methodReference.getDefiningClass();//TypeGenUtil.newType(methodReference.getDefiningClass()); sb.append(clazz); sb.append("->"); } sb.append(methodReference.getName()); sb.append('('); for (CharSequence paramType : methodReference.getParameterTypes()) { sb.append(paramType); } sb.append(')'); sb.append(methodReference.getReturnType()); return sb.toString(); }
Example 2
Source File: MethodInvocationInstruction.java From JAADAS with GNU General Public License v3.0 | 6 votes |
/** * Determine if register is used as floating point. * * Abstraction for static and non-static methods. Non-static methods need to ignore the first parameter (this) * @param isStatic if this method is static */ protected boolean isUsedAsFloatingPoint(DexBody body, int register, boolean isStatic) { MethodReference item = (MethodReference) ((ReferenceInstruction) instruction).getReference(); List<? extends CharSequence> paramTypes = item.getParameterTypes(); List<Integer> regs = getUsedRegistersNums(); if (paramTypes == null) return false; for (int i = 0, j = 0; i < regs.size(); i++, j++) { if (!isStatic && i == 0) { j--; continue; } if (regs.get(i) == register && isFloatLike(DexType.toSoot(paramTypes.get(j).toString()))) return true; if (DexType.isWide(paramTypes.get(j).toString())) i++; } return false; }
Example 3
Source File: MethodInvocationInstruction.java From JAADAS with GNU General Public License v3.0 | 6 votes |
/** * Determine if register is used as object. * * Abstraction for static and non-static methods. Non-static methods need to ignore the first parameter (this) * @param isStatic if this method is static */ protected boolean isUsedAsObject(DexBody body, int register, boolean isStatic) { MethodReference item = (MethodReference) ((ReferenceInstruction) instruction).getReference(); List<? extends CharSequence> paramTypes = item.getParameterTypes(); List<Integer> regs = getUsedRegistersNums(); if (paramTypes == null) return false; // we call a method on the register if (!isStatic && regs.get(0) == register) return true; // we call a method with register as a reftype paramter for (int i = 0, j = 0; i < regs.size(); i++, j++) { if (!isStatic && i == 0) { j--; continue; } if (regs.get(i) == register && (DexType.toSoot(paramTypes.get(j).toString()) instanceof RefType)) return true; if (DexType.isWide(paramTypes.get(j).toString())) i++; } return false; }
Example 4
Source File: ImmutableMethodReference.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull public static ImmutableMethodReference of(@Nonnull MethodReference methodReference) { if (methodReference instanceof ImmutableMethodReference) { return (ImmutableMethodReference)methodReference; } return new ImmutableMethodReference( methodReference.getDefiningClass(), methodReference.getName(), methodReference.getParameterTypes(), methodReference.getReturnType()); }
Example 5
Source File: ReferenceUtil.java From atlas with Apache License 2.0 | 5 votes |
public static void writeMethodDescriptor(Writer writer, MethodReference methodReference, boolean useImplicitReference) throws IOException { if (!useImplicitReference) { String clazz = TypeGenUtil.newType(methodReference.getDefiningClass()); writer.write(clazz); writer.write("->"); } writer.write(methodReference.getName()); writer.write('('); for (CharSequence paramType : methodReference.getParameterTypes()) { writer.write(paramType.toString()); } writer.write(')'); writer.write(methodReference.getReturnType()); }
Example 6
Source File: ImmutableMethodReference.java From zjdroid with Apache License 2.0 | 5 votes |
@Nonnull public static ImmutableMethodReference of(@Nonnull MethodReference methodReference) { if (methodReference instanceof ImmutableMethodReference) { return (ImmutableMethodReference)methodReference; } return new ImmutableMethodReference( methodReference.getDefiningClass(), methodReference.getName(), methodReference.getParameterTypes(), methodReference.getReturnType()); }
Example 7
Source File: MethodInvocationInstruction.java From JAADAS with GNU General Public License v3.0 | 5 votes |
public Set<Type> introducedTypes() { Set<Type> types = new HashSet<Type>(); MethodReference method = (MethodReference) (((ReferenceInstruction) instruction).getReference()); types.add(DexType.toSoot(method.getDefiningClass())); types.add(DexType.toSoot(method.getReturnType())); List<? extends CharSequence> paramTypes = method.getParameterTypes(); if (paramTypes != null) for (CharSequence type : paramTypes) types.add(DexType.toSoot(type.toString())); return types; }
Example 8
Source File: MethodInvocationInstruction.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * Return the SootMethodRef for the invoked method. * * @param invType The invocation type */ private SootMethodRef getSootMethodRef(InvocationType invType) { if (methodRef != null) return methodRef; MethodReference mItem = (MethodReference) ((ReferenceInstruction) instruction).getReference(); String tItem = mItem.getDefiningClass(); String className = tItem; Debug.printDbg("tItem: ", tItem ," class name: ", className); if (className.startsWith("[")) { className = "java.lang.Object"; } else { className = dottedClassName (tItem); } SootClass sc = SootResolver.v().makeClassRef(className); if (invType == InvocationType.Interface && sc.isPhantom()) sc.setModifiers(sc.getModifiers() | Modifier.INTERFACE); String methodName = mItem.getName(); Type returnType = DexType.toSoot(mItem.getReturnType()); List<Type> parameterTypes = new ArrayList<Type>(); List<? extends CharSequence> paramTypes = mItem.getParameterTypes(); if (paramTypes != null) for (CharSequence type : paramTypes) parameterTypes.add(DexType.toSoot(type.toString())); Debug.printDbg("sc: ", sc); Debug.printDbg("methodName: ", methodName); Debug.printDbg("parameterTypes: "); for (Type t: parameterTypes) Debug.printDbg(" t: ", t); Debug.printDbg("returnType: ", returnType); Debug.printDbg("isStatic: ", invType == InvocationType.Static); methodRef = Scene.v().makeMethodRef(sc, methodName, parameterTypes, returnType, invType == InvocationType.Static); return methodRef; }
Example 9
Source File: MethodInvocationInstruction.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * Build the parameters of this invocation. * * The first parameter is the instance for which the method is invoked (if method is non-static). * * @param body the body to build for and into * @param isStatic if method is static * * @return the converted parameters */ protected List<Local> buildParameters(DexBody body, boolean isStatic) { MethodReference item = getTargetMethodReference(); List<? extends CharSequence> paramTypes = item.getParameterTypes(); List<Local> parameters = new ArrayList<Local>(); List<Integer> regs = getUsedRegistersNums(); Debug.printDbg(" [methodIdItem]: ", item); Debug.printDbg(" params types:"); if (paramTypes != null) { for (CharSequence t: paramTypes) { Debug.printDbg(" t: ", t); } } Debug.printDbg(" used registers (", regs.size() ,"): "); for (int i: regs) { Debug.printDbg( " r: ", i); } // i: index for register // j: index for parameter type for (int i = 0, j = 0; i < regs.size(); i++, j++) { parameters.add (body.getRegisterLocal (regs.get(i))); // if method is non-static the first parameter is the instance // pointer and has no corresponding parameter type if (!isStatic && i == 0) { j--; continue; } // If current parameter is wide ignore the next register. // No need to increment j as there is one parameter type // for those two registers. if (paramTypes != null && DexType.isWide(paramTypes.get(j).toString())) { i++; } } return parameters; }
Example 10
Source File: ImmutableMethodReference.java From HeyGirl with Apache License 2.0 | 5 votes |
@Nonnull public static ImmutableMethodReference of(@Nonnull MethodReference methodReference) { if (methodReference instanceof ImmutableMethodReference) { return (ImmutableMethodReference)methodReference; } return new ImmutableMethodReference( methodReference.getDefiningClass(), methodReference.getName(), methodReference.getParameterTypes(), methodReference.getReturnType()); }
Example 11
Source File: ImmutableMethodReference.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull public static ImmutableMethodReference of(@Nonnull MethodReference methodReference) { if (methodReference instanceof ImmutableMethodReference) { return (ImmutableMethodReference)methodReference; } return new ImmutableMethodReference( methodReference.getDefiningClass(), methodReference.getName(), methodReference.getParameterTypes(), methodReference.getReturnType()); }