Java Code Examples for com.strobel.assembler.metadata.TypeDefinition#getDeclaredMethods()

The following examples show how to use com.strobel.assembler.metadata.TypeDefinition#getDeclaredMethods() . 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: DecompilerLinkProvider.java    From Luyten with Apache License 2.0 6 votes vote down vote up
private MethodDefinition findMethodInType(TypeDefinition typeDef, String uniqueStr) {
	String[] linkParts = uniqueStr.split("\\|");
	if (linkParts.length != 5)
		return null;
	String methodName = linkParts[3];
	String methodErasedSignature = linkParts[4];
	if (methodName.trim().length() <= 0 || methodErasedSignature.trim().length() <= 0)
		return null;
	List<MethodDefinition> declaredMethods = typeDef.getDeclaredMethods();
	if (declaredMethods == null)
		return null;
	boolean isFound = false;
	for (MethodDefinition declaredMethod : declaredMethods) {
		isFound = (declaredMethod != null && methodName.equals(declaredMethod.getName()));
		isFound = (isFound && methodErasedSignature.equals(declaredMethod.getErasedSignature()));
		if (isFound) {
			if (declaredMethod.isSynthetic() && !settings.getShowSyntheticMembers()) {
				return null;
			} else {
				return declaredMethod;
			}
		}
	}
	return null;
}
 
Example 2
Source File: LockProblems.java    From huntbugs with Apache License 2.0 5 votes vote down vote up
private static MethodDefinition findReplacement(String name, TypeDefinition target) {
    for (MethodDefinition md : target.getDeclaredMethods()) {
        if (!md.isPublic() || !md.getSignature().equals("()V"))
            continue;
        if (name.equals("wait") && md.getName().equals("await"))
            return md;
        if (name.equals("notify") && (md.getName().equals("signal") || md.getName().equals("countDown")))
            return md;
        if (name.equals("notifyAll") && (md.getName().equals("signalAll") || md.getName().equals("countDown")))
            return md;
    }
    return null;

}
 
Example 3
Source File: FinalizerContract.java    From huntbugs with Apache License 2.0 5 votes vote down vote up
private static MethodDefinition getSuperfinalizer(TypeDefinition type) {
    TypeDefinition superType = type.getBaseType().resolve();
    if (superType == null || Types.isObject(superType))
        return null;
    for (MethodDefinition child : superType.getDeclaredMethods()) {
        if (isFinalizer(child))
            return child;
    }
    return getSuperfinalizer(superType);
}
 
Example 4
Source File: UncalledPrivateMethod.java    From huntbugs with Apache License 2.0 5 votes vote down vote up
@Override
protected void visitType(TypeDefinition td) {
    TypeReference tr = td.getDeclaringType();
    if(tr == null) return;
    TypeDefinition outer = tr.resolve();
    if(outer == null || !outer.isAnonymous()) return;
    for(MethodDefinition md : td.getDeclaredMethods()) {
        extractCalls(md, mr -> {
            mis.add(new MemberInfo(mr));
            return true;
        });
    }
}
 
Example 5
Source File: MethodStats.java    From huntbugs with Apache License 2.0 5 votes vote down vote up
@Override
protected void visitType(TypeDefinition td) {
    for (MethodDefinition md : td.getDeclaredMethods()) {
        MethodData mdata = getMethodData(md);
        if (md.isFinal() || td.isFinal() || md.isStatic() || md.isPrivate()) {
            mdata.flags |= METHOD_FINAL;
        }
        visitMethod(mdata, md);
        for (MethodDefinition superMethod : Methods.findSuperMethods(md)) {
            getMethodData(superMethod).addSubMethod(mdata);
        }
    }
}
 
Example 6
Source File: Methods.java    From huntbugs with Apache License 2.0 5 votes vote down vote up
public static MethodDefinition findMethod(TypeDefinition td, MemberInfo mi) {
    if(td == null)
        return null;
    for(MethodDefinition decl : td.getDeclaredMethods()) {
        if(decl.getName().equals(mi.getName())) {
            String sig1 = decl.getErasedSignature();
            String sig2 = mi.getSignature();
            if(sig1 == sig2)
                return decl;
            if(sig1.substring(0, sig1.indexOf(')')).equals(sig2.substring(0, sig2.indexOf(')'))))
                return decl;
        }
    }
    return null;
}