fix: prevent null type in code variables
This commit is contained in:
@@ -62,6 +62,7 @@ import jadx.core.dex.visitors.rename.CodeRenameVisitor;
|
||||
import jadx.core.dex.visitors.rename.RenameVisitor;
|
||||
import jadx.core.dex.visitors.shrink.CodeShrinkVisitor;
|
||||
import jadx.core.dex.visitors.ssa.SSATransform;
|
||||
import jadx.core.dex.visitors.typeinference.FinishTypeInference;
|
||||
import jadx.core.dex.visitors.typeinference.TypeInferenceVisitor;
|
||||
import jadx.core.dex.visitors.usage.UsageInfoVisitor;
|
||||
import jadx.core.utils.exceptions.JadxRuntimeException;
|
||||
@@ -130,6 +131,7 @@ public class Jadx {
|
||||
if (args.isDebugInfo()) {
|
||||
passes.add(new DebugInfoApplyVisitor());
|
||||
}
|
||||
passes.add(new FinishTypeInference());
|
||||
if (args.getUseKotlinMethodsForVarNames() != JadxArgs.UseKotlinMethodsForVarNames.DISABLE) {
|
||||
passes.add(new ProcessKotlinInternals());
|
||||
}
|
||||
@@ -204,6 +206,7 @@ public class Jadx {
|
||||
if (args.isDebugInfo()) {
|
||||
passes.add(new DebugInfoApplyVisitor());
|
||||
}
|
||||
passes.add(new FinishTypeInference());
|
||||
passes.add(new CodeRenameVisitor());
|
||||
passes.add(new DeboxingVisitor());
|
||||
passes.add(new ModVisitor());
|
||||
|
||||
@@ -56,24 +56,11 @@ public class DebugInfoApplyVisitor extends AbstractVisitor {
|
||||
mth.remove(AType.LOCAL_VARS_DEBUG_INFO);
|
||||
}
|
||||
processMethodParametersAttribute(mth);
|
||||
checkTypes(mth);
|
||||
} catch (Exception e) {
|
||||
mth.addWarnComment("Failed to apply debug info", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkTypes(MethodNode mth) {
|
||||
if (mth.isNoCode() || mth.getSVars().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
mth.getSVars().forEach(var -> {
|
||||
ArgType type = var.getTypeInfo().getType();
|
||||
if (!type.isTypeKnown()) {
|
||||
mth.addWarnComment("Type inference failed for: " + var.getDetailedVarInfo(mth));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void applyDebugInfo(MethodNode mth) {
|
||||
if (Consts.DEBUG_TYPE_INFERENCE) {
|
||||
LOG.info("Apply debug info for method: {}", mth);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package jadx.core.dex.visitors.typeinference;
|
||||
|
||||
import jadx.core.dex.instructions.args.ArgType;
|
||||
import jadx.core.dex.nodes.MethodNode;
|
||||
import jadx.core.dex.visitors.AbstractVisitor;
|
||||
import jadx.core.dex.visitors.JadxVisitor;
|
||||
|
||||
@JadxVisitor(
|
||||
name = "Finish Type Inference",
|
||||
desc = "Check used types",
|
||||
runAfter = {
|
||||
TypeInferenceVisitor.class
|
||||
}
|
||||
)
|
||||
public final class FinishTypeInference extends AbstractVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode mth) {
|
||||
if (mth.isNoCode() || mth.getSVars().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
mth.getSVars().forEach(var -> {
|
||||
ArgType type = var.getTypeInfo().getType();
|
||||
if (!type.isTypeKnown()) {
|
||||
mth.addWarnComment("Type inference failed for: " + var.getDetailedVarInfo(mth));
|
||||
}
|
||||
ArgType codeVarType = var.getCodeVar().getType();
|
||||
if (codeVarType == null) {
|
||||
var.getCodeVar().setType(ArgType.UNKNOWN);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user