use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class MethodInvokeVisitor method processInvoke.
private void processInvoke(MethodNode parentMth, BaseInvokeNode invokeInsn) {
MethodInfo callMth = invokeInsn.getCallMth();
if (callMth.getArgsCount() == 0) {
return;
}
IMethodDetails mthDetails = root.getMethodUtils().getMethodDetails(invokeInsn);
if (mthDetails == null) {
if (Consts.DEBUG) {
parentMth.addDebugComment("Method info not found: " + callMth);
}
processUnknown(invokeInsn);
} else {
if (mthDetails.isVarArg()) {
ArgType last = Utils.last(mthDetails.getArgTypes());
if (last != null && last.isArray()) {
invokeInsn.add(AFlag.VARARG_CALL);
}
}
processOverloaded(parentMth, invokeInsn, mthDetails);
}
}
use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class MethodInvokeVisitor method processOverloaded.
private void processOverloaded(MethodNode parentMth, BaseInvokeNode invokeInsn, IMethodDetails mthDetails) {
MethodInfo callMth = invokeInsn.getCallMth();
ArgType callCls = getCallClassFromInvoke(parentMth, invokeInsn, callMth);
List<IMethodDetails> overloadMethods = root.getMethodUtils().collectOverloadedMethods(callCls, callMth);
if (overloadMethods.isEmpty()) {
// not overloaded
return;
}
// resolve generic type variables
Map<ArgType, ArgType> typeVarsMapping = getTypeVarsMapping(invokeInsn);
IMethodDetails effectiveMthDetails = resolveTypeVars(mthDetails, typeVarsMapping);
List<IMethodDetails> effectiveOverloadMethods = new ArrayList<>(overloadMethods.size() + 1);
for (IMethodDetails overloadMethod : overloadMethods) {
effectiveOverloadMethods.add(resolveTypeVars(overloadMethod, typeVarsMapping));
}
effectiveOverloadMethods.add(effectiveMthDetails);
// search cast types to resolve overloading
int argsOffset = invokeInsn.getFirstArgOffset();
List<ArgType> compilerVarTypes = collectCompilerVarTypes(invokeInsn, argsOffset);
List<ArgType> castTypes = searchCastTypes(parentMth, effectiveMthDetails, effectiveOverloadMethods, compilerVarTypes);
applyArgsCast(invokeInsn, argsOffset, compilerVarTypes, castTypes);
}
use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class FixAccessModifiers method fixMethodVisibility.
private static int fixMethodVisibility(MethodNode mth) {
AccessInfo accessFlags = mth.getAccessFlags();
if (accessFlags.isPublic()) {
return -1;
}
MethodOverrideAttr overrideAttr = mth.get(AType.METHOD_OVERRIDE);
if (overrideAttr != null && !overrideAttr.getOverrideList().isEmpty()) {
// visibility can't be weaker
IMethodDetails parentMD = overrideAttr.getOverrideList().get(0);
AccessInfo parentAccInfo = new AccessInfo(parentMD.getRawAccessFlags(), AccessInfo.AFType.METHOD);
if (accessFlags.isVisibilityWeakerThan(parentAccInfo)) {
return parentAccInfo.getVisibility().rawValue();
}
}
if (mth.getUseIn().isEmpty()) {
return -1;
}
ClassNode thisTopParentCls = mth.getParentClass().getTopParentClass();
for (MethodNode useMth : mth.getUseIn()) {
ClassNode useInTPCls = useMth.getParentClass().getTopParentClass();
if (!useInTPCls.equals(thisTopParentCls)) {
return AccessFlags.PUBLIC;
}
}
return -1;
}
use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class ModVisitor method processAnonymousConstructor.
/**
* For args in anonymous constructor invoke apply:
* - forbid inline into constructor call
* - make variables final (compiler require this implicitly)
*/
private static void processAnonymousConstructor(MethodNode mth, ConstructorInsn co) {
IMethodDetails callMthDetails = mth.root().getMethodUtils().getMethodDetails(co);
if (!(callMthDetails instanceof MethodNode)) {
return;
}
MethodNode callMth = (MethodNode) callMthDetails;
if (!callMth.contains(AFlag.ANONYMOUS_CONSTRUCTOR) || callMth.contains(AFlag.NO_SKIP_ARGS)) {
return;
}
SkipMethodArgsAttr attr = callMth.get(AType.SKIP_MTH_ARGS);
if (attr != null) {
int argsCount = Math.min(callMth.getMethodInfo().getArgsCount(), co.getArgsCount());
for (int i = 0; i < argsCount; i++) {
if (attr.isSkip(i)) {
anonymousCallArgMod(co.getArg(i));
}
}
} else {
// additional info not available apply mods to all args (the safest solution)
co.getArguments().forEach(ModVisitor::anonymousCallArgMod);
}
}
use of jadx.core.dex.nodes.IMethodDetails in project jadx by skylot.
the class OverrideMethodVisitor method getMethodNodes.
@NotNull
private List<MethodNode> getMethodNodes(MethodNode mth, List<IMethodDetails> overrideList) {
List<MethodNode> list = new ArrayList<>(1 + overrideList.size());
list.add(mth);
for (IMethodDetails md : overrideList) {
if (md instanceof MethodNode) {
list.add((MethodNode) md);
}
}
return list;
}
Aggregations