@Nonnull @Override public String getName() { return method.getName(); }
private void visitMethod(ClassDef classDef, Method method, MethodVisitor mv) { mv.visitCode(); String methodName = method.getName(); if (methodName.equals("<clinit>")) { visitClInitStub(mv); } else if (methodName.equals("<init>")) { visitInitStub(classDef, mv); } else if (methodName.equals("hashCode") && method.getReturnType().equals("I")) { visitCallObjectHashCode(mv); } else { visitMethodStub(mv); } // Do this at the end so ASM can calculate max stack and locals sizes mv.visitMaxs(0, 0); mv.visitEnd(); }
for (Method method : methods) { int access = method.getAccessFlags(); String name = method.getName(); String desc = buildDescriptor(method); String signature = null; MethodVisitor mv = classWriter.visitMethod(access, name, desc, signature, exceptions); if (method.getImplementation() != null) { if (method.getName().equals("<init>") && desc.equals("()V")) { hasDefaultConstructor = true;
method.getName(), method.getParameters(), method.getReturnType(),
MethodImplementation code = method.getImplementation(); if (code == null) { throw new RuntimeException("error: no code for method " + method.getName());
public static void writeEmptyMethodTo(IndentingWriter writer, Method method, BaksmaliOptions options) throws IOException { writer.write(".method "); writeAccessFlags(writer, method.getAccessFlags()); writer.write(method.getName()); writer.write("("); ImmutableList<MethodParameter> methodParameters = ImmutableList.copyOf(method.getParameters()); for (MethodParameter parameter: methodParameters) { writer.write(parameter.getType()); } writer.write(")"); writer.write(method.getReturnType()); writer.write('\n'); writer.indent(4); writeParameters(writer, method, methodParameters, options); String containingClass = null; if (options.implicitReferences) { containingClass = method.getDefiningClass(); } AnnotationFormatter.writeTo(writer, method.getAnnotations(), containingClass); writer.deindent(4); writer.write(".end method\n"); }
/** * Retrieve the SootMethod equivalent of this method * * @return the SootMethod of this method */ public SootMethod makeSootMethod(final Method method) { int accessFlags = method.getAccessFlags(); // get the name of the method String name = method.getName(); List<SootClass> thrownExceptions = getThrownExceptions(method); List<Type> parameterTypes = getParameterTypes(method); // retrieve the return type of this method Type returnType = DexType.toSoot(method.getReturnType()); // Build soot method by all available parameters SootMethod sm = declaringClass.getMethodUnsafe(name, parameterTypes, returnType); if (sm == null) { sm = Scene.v().makeSootMethod(name, parameterTypes, returnType, accessFlags, thrownExceptions); } // if the method is abstract or native, no code needs to be transformed int flags = method.getAccessFlags(); if (Modifier.isAbstract(flags) || Modifier.isNative(flags)) { return sm; } if (Options.v().oaat() && declaringClass.resolvingLevel() <= SootClass.SIGNATURES) { return sm; } // sets the method source by adding its body as the active body sm.setSource(createMethodSource(method)); return sm; }
writer.write(method.getName()); writer.write("("); for (MethodParameter parameter: methodParameters) {
private static boolean methodNeedsModification(@Nonnull ClassDef classDef, @Nonnull Method method, boolean isAndFix) { if (isAndFix) { return true; } else if (method.getName().equals("<init>")) { return true; } return false; }
@Override public boolean isClinit() { return eMethod.getName().equals(MethodReference.clinitName.toString()); }
@Override public boolean isClinit() { return eMethod.getName().equals(MethodReference.clinitName.toString()); }
@Override public boolean isInit() { return eMethod.getName().equals(MethodReference.initAtom.toString()); }
@Override public boolean isInit() { return eMethod.getName().equals(MethodReference.initAtom.toString()); }
private String getMethodFullName(Method method) { StringBuilder stringBuilder = new StringBuilder(); String methodName = method.getName(); stringBuilder.append(methodName).append("("); for (CharSequence c:method.getParameterTypes()){ stringBuilder.append(c); } stringBuilder.append(")").append(method.getReturnType()); return stringBuilder.toString(); }
@Override public Method read(String className, String member) throws Exception { org.jf.dexlib2.iface.ClassDef classDef = (org.jf.dexlib2.iface.ClassDef) reader.read(className,null); for(Method method:classDef.getMethods()){ if (method.getName().equals(member)){ return method; } } return null; } }
public ControlFlowGraph(Method method) { this(getFlatMethod(method)); String definingClass = method.getDefiningClass(); this.identifier = definingClass + "." + method.getName() + "()" + method.getReturnType(); // this.identifier = definingClass.substring(definingClass.lastIndexOf("/")+1) + method.getName() + "(" + method.getReturnType() + ")"; this.identifier = this.identifier.replace(";", ""); this.shortIdentifier = identifier.substring(definingClass.lastIndexOf("/")+1); }
public static ImmutableMethod of(Method method) { if (method instanceof ImmutableMethod) { return (ImmutableMethod)method; } return new ImmutableMethod( method.getDefiningClass(), method.getName(), method.getParameters(), method.getReturnType(), method.getAccessFlags(), method.getAnnotations(), method.getImplementation()); }
public static ImmutableMethod of(Method method) { if (method instanceof ImmutableMethod) { return (ImmutableMethod)method; } return new ImmutableMethod( method.getDefiningClass(), method.getName(), method.getParameters(), method.getReturnType(), method.getAccessFlags(), method.getAnnotations(), method.getImplementation()); }
private void verifyDexFile(DexFile dexFile) { Assert.assertEquals(1, dexFile.getClasses().size()); ClassDef cls = Lists.newArrayList(dexFile.getClasses()).get(0); Assert.assertEquals("Lcls1;", cls.getType()); Assert.assertEquals(1, Lists.newArrayList(cls.getMethods()).size()); Method method = Iterators.getNext(cls.getMethods().iterator(), null); Assert.assertEquals("method1", method.getName()); Assert.assertEquals(1, Lists.newArrayList(method.getImplementation().getInstructions()).size()); Instruction instruction = Lists.newArrayList(method.getImplementation().getInstructions().iterator()).get(0); Assert.assertEquals(Opcode.INVOKE_CUSTOM, instruction.getOpcode()); Assert.assertTrue(((Instruction35c) instruction).getReference() instanceof CallSiteReference); } }