Java Code Examples for org.jf.dexlib2.iface.Method#getDefiningClass()

The following examples show how to use org.jf.dexlib2.iface.Method#getDefiningClass() . 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: ImmutableMethod.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 2
Source File: ImmutableMethod.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 3
Source File: ImmutableMethod.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 4
Source File: ControlFlowGraph.java    From CFGScanDroid with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 5
Source File: ImmutableMethod.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 6
Source File: DexBody.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param code the codeitem that is contained in this body
 * @param method the method that is associated with this body
 */
public DexBody(DexFile dexFile, Method method, RefType declaringClassType) {
    MethodImplementation code = method.getImplementation();
    if (code == null)
        throw new RuntimeException("error: no code for method "+ method.getName());
    this.declaringClassType = declaringClassType;
    tries = code.getTryBlocks();
    methodSignature = method.getDefiningClass() +": "+ method.getReturnType() +" "+ method.getName() +"(";
    for (MethodParameter mp: method.getParameters())
        methodSignature += mp.getType() +",";

    List<? extends CharSequence> paramTypes = method.getParameterTypes();
    if (paramTypes != null) {
        parameterTypes = new ArrayList<Type>();
        for (CharSequence type : paramTypes)
            parameterTypes.add(DexType.toSoot(type.toString()));
    } else {
    	parameterTypes = Collections.emptyList();
    }
    
    isStatic = Modifier.isStatic(method.getAccessFlags());
    numRegisters = code.getRegisterCount();
    numParameterRegisters = MethodUtil.getParameterRegisterCount(method);
    if (!isStatic)
        numParameterRegisters--;

    instructions = new ArrayList<DexlibAbstractInstruction>();
    instructionAtAddress = new HashMap<Integer, DexlibAbstractInstruction>();

    registerLocals = new Local[numRegisters];

    int address = 0;
    
    for (Instruction instruction : code.getInstructions()) {
        DexlibAbstractInstruction dexInstruction = fromInstruction(instruction, address);
        instructions.add(dexInstruction);
        instructionAtAddress.put(address, dexInstruction);
        Debug.printDbg(" put instruction '", dexInstruction ,"' at 0x", Integer.toHexString(address));
        address += instruction.getCodeUnits();
    }
    
    // Check taken from Android's dalvik/libdex/DexSwapVerify.cpp
    if (numParameterRegisters > numRegisters)
    	throw new RuntimeException("Malformed dex file: insSize (" + numParameterRegisters
    			+ ") > registersSize (" + numRegisters + ")");
    
    for (DebugItem di: code.getDebugItems()) {
        if (di instanceof ImmutableLineNumber) {
            ImmutableLineNumber ln = (ImmutableLineNumber)di;
            DexlibAbstractInstruction ins = instructionAtAddress(ln.getCodeAddress());
            if (ins == null) {
            	Debug.printDbg("Line number tag pointing to invalid offset: " + ln.getCodeAddress());
            	continue;
            }
            ins.setLineNumber(ln.getLineNumber());
            Debug.printDbg("Add line number tag " + ln.getLineNumber() + " for instruction: "
                    + instructionAtAddress(ln.getCodeAddress()));
        }
    }

    this.dexFile = dexFile;
}