Class FixTypesVisitor

java.lang.Object
jadx.core.dex.visitors.AbstractVisitor
jadx.core.dex.visitors.typeinference.FixTypesVisitor
All Implemented Interfaces:
IDexTreeVisitor

public final class FixTypesVisitor extends AbstractVisitor
  • Field Details

  • Constructor Details

    • FixTypesVisitor

      public FixTypesVisitor()
  • Method Details

    • init

      public void init(RootNode root)
      Description copied from interface: IDexTreeVisitor
      Called after loading dex tree, but before visitor traversal.
      Specified by:
      init in interface IDexTreeVisitor
      Overrides:
      init in class AbstractVisitor
    • visit

      public void visit(MethodNode mth)
      Description copied from interface: IDexTreeVisitor
      Visit method
      Specified by:
      visit in interface IDexTreeVisitor
      Overrides:
      visit in class AbstractVisitor
    • checkTypes

      private static boolean checkTypes(MethodNode mth)
      Check if all types resolved
    • runMultiVariableSearch

      private boolean runMultiVariableSearch(MethodNode mth)
    • setBestType

      private boolean setBestType(MethodNode mth, SSAVar ssaVar)
    • calculateFromBounds

      private boolean calculateFromBounds(MethodNode mth, SSAVar ssaVar)
    • selectBestTypeFromBounds

      private Optional<ArgType> selectBestTypeFromBounds(Set<ITypeBound> bounds)
    • tryPossibleTypes

      private boolean tryPossibleTypes(MethodNode mth, SSAVar var, ArgType type)
    • makePossibleTypesList

      private List<ArgType> makePossibleTypesList(ArgType type, @Nullable @Nullable SSAVar var)
    • tryDeduceTypes

      private boolean tryDeduceTypes(MethodNode mth)
    • deduceType

      private boolean deduceType(MethodNode mth, SSAVar var)
    • tryRemoveGenerics

      private boolean tryRemoveGenerics(MethodNode mth)
    • tryRawType

      private boolean tryRawType(MethodNode mth, SSAVar var)
    • checkRawType

      private boolean checkRawType(MethodNode mth, SSAVar var, ArgType objType)
    • applyFieldType

      private Boolean applyFieldType(MethodNode mth)
      Use type for var assigned from field (IGET or SGET). Insert additional casts at var use places.
    • tryFieldTypeWithNewCasts

      private boolean tryFieldTypeWithNewCasts(MethodNode mth, SSAVar ssaVar, boolean insertCasts)
    • insertExplicitUseCast

      private boolean insertExplicitUseCast(MethodNode mth, SSAVar ssaVar, RegisterArg useArg, ArgType fieldType)
    • tryRestoreTypeVarCasts

      private boolean tryRestoreTypeVarCasts(MethodNode mth)
      Fix check casts to type var extend type:
      <T extends Comparable> T var = (Comparable) obj; => T var = (T) obj;
    • restoreTypeVarCasts

      private int restoreTypeVarCasts(SSAVar var)
    • tryInsertCasts

      private boolean tryInsertCasts(MethodNode mth)
    • tryInsertVarCast

      private int tryInsertVarCast(MethodNode mth, SSAVar var)
    • insertUseCasts

      private int insertUseCasts(MethodNode mth, SSAVar var)
    • insertAssignCast

      @Nullable private @Nullable IndexInsnNode insertAssignCast(MethodNode mth, SSAVar var, ArgType castType)
    • insertUseCast

      @Nullable private @Nullable IndexInsnNode insertUseCast(MethodNode mth, RegisterArg useArg, ArgType castType)
    • makeCastInsn

      private IndexInsnNode makeCastInsn(RegisterArg result, RegisterArg arg, ArgType castType)
    • trySplitConstInsns

      private boolean trySplitConstInsns(MethodNode mth)
    • checkAndSplitConstInsn

      private boolean checkAndSplitConstInsn(MethodNode mth, SSAVar var)
    • dupConst

      private boolean dupConst(MethodNode mth, SSAVar var)
    • splitByPhi

      private static boolean splitByPhi(MethodNode mth, SSAVar var)
      For every PHI make separate CONST insn
    • tryInsertAdditionalMove

      private boolean tryInsertAdditionalMove(MethodNode mth)
    • tryInsertAdditionalInsn

      private int tryInsertAdditionalInsn(MethodNode mth, PhiInsn phiInsn)
      Add MOVE instruction before PHI in bound blocks to make 'soft' type link. This allows using different types in blocks merged by PHI.
    • getCommonTypeForPhiArgs

      @Nullable private @Nullable ArgType getCommonTypeForPhiArgs(PhiInsn phiInsn)
    • insertMovesForPhi

      private int insertMovesForPhi(MethodNode mth, PhiInsn phiInsn, boolean apply)
    • insertMove

      private void insertMove(MethodNode mth, BlockNode blockNode, PhiInsn phiInsn, RegisterArg reg)
    • checkBlockForInsnInsert

      @Nullable private @Nullable BlockNode checkBlockForInsnInsert(BlockNode blockNode)
    • tryWiderObjects

      private boolean tryWiderObjects(MethodNode mth, SSAVar var)
    • tryToFixIncompatiblePrimitives

      private boolean tryToFixIncompatiblePrimitives(MethodNode mth)
    • processIncompatiblePrimitives

      private boolean processIncompatiblePrimitives(MethodNode mth, SSAVar var)
    • fixBooleanUsage

      private boolean fixBooleanUsage(MethodNode mth, RegisterArg boundArg)
    • notBooleanToInt

      private InsnNode notBooleanToInt(ArithNode insn, RegisterArg boundArg)
    • prepareBooleanConvertInsn

      private TernaryInsn prepareBooleanConvertInsn(RegisterArg resultArg, RegisterArg boundArg, ArgType useType)
    • tryToForceImmutableTypes

      private boolean tryToForceImmutableTypes(MethodNode mth)
    • forceImmutableType

      private boolean forceImmutableType(SSAVar ssaVar)
    • getName

      public String getName()
      Description copied from interface: IDexTreeVisitor
      Visitor short id
      Specified by:
      getName in interface IDexTreeVisitor
      Overrides:
      getName in class AbstractVisitor