Code clean up
This commit is contained in:
@@ -19,7 +19,7 @@ import com.beust.jcommander.ParameterDescription;
|
||||
import com.beust.jcommander.ParameterException;
|
||||
|
||||
public class JadxArgs {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(JadxArgs.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JadxArgs.class);
|
||||
|
||||
@Parameter(description = "<input files> (.dex, .apk, .jar or .class)", required = true)
|
||||
protected List<String> files;
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class ProcessClass implements Runnable {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(ProcessClass.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessClass.class);
|
||||
|
||||
private final ClassNode cls;
|
||||
private final List<IDexTreeVisitor> passes;
|
||||
|
||||
@@ -24,14 +24,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.android.dx.rop.code.AccessFlags;
|
||||
|
||||
public class ClassGen {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(ClassGen.class);
|
||||
|
||||
private final ClassNode cls;
|
||||
private final ClassGen parentGen;
|
||||
private final AnnotationGen annotationGen;
|
||||
|
||||
@@ -3,18 +3,17 @@ package jadx.codegen;
|
||||
import jadx.utils.exceptions.JadxRuntimeException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CodeWriter {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(CodeWriter.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CodeWriter.class);
|
||||
private static final int MAX_FILENAME_LENGTH = 128;
|
||||
|
||||
public final static String NL = System.getProperty("line.separator");
|
||||
public final static String INDENT = "\t";
|
||||
public static final String NL = System.getProperty("line.separator");
|
||||
public static final String INDENT = "\t";
|
||||
|
||||
private StringBuilder buf = new StringBuilder();
|
||||
private String indentStr;
|
||||
@@ -155,11 +154,11 @@ public class CodeWriter {
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
makeDirsForFile(file);
|
||||
out = new PrintWriter(file);
|
||||
out = new PrintWriter(file, "UTF-8");
|
||||
String code = buf.toString();
|
||||
code = removeFirstEmptyLine(code);
|
||||
out.print(code);
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (Exception e) {
|
||||
LOG.error("Save file error", e);
|
||||
} finally {
|
||||
if (out != null)
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class InsnGen {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(InsnGen.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(InsnGen.class);
|
||||
|
||||
protected final MethodGen mgen;
|
||||
protected final MethodNode mth;
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||
import com.android.dx.rop.code.AccessFlags;
|
||||
|
||||
public class MethodGen {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(MethodGen.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MethodGen.class);
|
||||
|
||||
private final MethodNode mth;
|
||||
private final Set<String> mthArgsDecls;
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RegionGen extends InsnGen {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(RegionGen.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RegionGen.class);
|
||||
|
||||
public RegionGen(MethodGen mgen, MethodNode mth) {
|
||||
super(mgen, mth, false);
|
||||
|
||||
@@ -5,12 +5,8 @@ import jadx.dex.instructions.args.RegisterArg;
|
||||
import jadx.dex.instructions.args.TypedVar;
|
||||
import jadx.dex.nodes.DexNode;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class LocalVarInfo extends RegisterArg {
|
||||
|
||||
private final static Logger LOG = LoggerFactory.getLogger(LocalVarInfo.class);
|
||||
private boolean isEnd;
|
||||
|
||||
public LocalVarInfo(DexNode dex, int rn, int nameId, int typeId, int signId) {
|
||||
@@ -31,8 +27,6 @@ public class LocalVarInfo extends RegisterArg {
|
||||
TypedVar tv = new TypedVar(type);
|
||||
tv.setName(name);
|
||||
setTypedVar(tv);
|
||||
|
||||
// LOG.trace("local var: {}, sign: {}", tv, sign);
|
||||
}
|
||||
|
||||
public void start(int addr, int line) {
|
||||
|
||||
@@ -10,9 +10,6 @@ import jadx.dex.nodes.InsnNode;
|
||||
import jadx.dex.nodes.MethodNode;
|
||||
import jadx.utils.exceptions.DecodeException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.android.dx.io.Code;
|
||||
import com.android.dx.io.OpcodeInfo;
|
||||
import com.android.dx.io.Opcodes;
|
||||
@@ -23,8 +20,6 @@ import com.android.dx.io.instructions.SparseSwitchPayloadDecodedInstruction;
|
||||
|
||||
public class InsnDecoder {
|
||||
|
||||
private final static Logger LOG = LoggerFactory.getLogger(InsnDecoder.class);
|
||||
|
||||
private final MethodNode method;
|
||||
private final DecodedInstruction[] insnArr;
|
||||
private final DexNode dex;
|
||||
@@ -35,25 +30,20 @@ public class InsnDecoder {
|
||||
this.insnArr = DecodedInstruction.decodeAll(mthCode.getInstructions());
|
||||
}
|
||||
|
||||
public InsnNode[] run() {
|
||||
public InsnNode[] run() throws DecodeException {
|
||||
InsnNode[] instructions = new InsnNode[insnArr.length];
|
||||
|
||||
for (int i = 0; i < insnArr.length; i++) {
|
||||
try {
|
||||
DecodedInstruction rawInsn = insnArr[i];
|
||||
if (rawInsn != null) {
|
||||
InsnNode insn = decode(rawInsn, i);
|
||||
if (insn != null) {
|
||||
insn.setOffset(i);
|
||||
insn.setInsnHashCode(calcHashCode(rawInsn));
|
||||
}
|
||||
instructions[i] = insn;
|
||||
} else {
|
||||
instructions[i] = null;
|
||||
DecodedInstruction rawInsn = insnArr[i];
|
||||
if (rawInsn != null) {
|
||||
InsnNode insn = decode(rawInsn, i);
|
||||
if (insn != null) {
|
||||
insn.setOffset(i);
|
||||
insn.setInsnHashCode(calcHashCode(rawInsn));
|
||||
}
|
||||
} catch (DecodeException e) {
|
||||
LOG.error("Instruction decode error", e);
|
||||
System.exit(1);
|
||||
instructions[i] = insn;
|
||||
} else {
|
||||
instructions[i] = null;
|
||||
}
|
||||
}
|
||||
return instructions;
|
||||
|
||||
@@ -20,9 +20,9 @@ public class TypedVar {
|
||||
/**
|
||||
* This method must be used very carefully
|
||||
*/
|
||||
public boolean forceSetType(ArgType type) {
|
||||
if (type != null && !type.equals(type)) {
|
||||
this.type = type;
|
||||
public boolean forceSetType(ArgType newType) {
|
||||
if (newType != null && !type.equals(newType)) {
|
||||
type = newType;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
|
||||
public class BlockNode extends AttrNode implements IBlock {
|
||||
|
||||
private int id;
|
||||
private final int startOffset;
|
||||
private final List<InsnNode> instructions = new ArrayList<InsnNode>(2);
|
||||
|
||||
@@ -26,12 +27,9 @@ public class BlockNode extends AttrNode implements IBlock {
|
||||
private BlockRegState startState;
|
||||
private BlockRegState endState;
|
||||
|
||||
private int id;
|
||||
public static int initialID;
|
||||
|
||||
public BlockNode(MethodNode mth, int offset) {
|
||||
public BlockNode(MethodNode mth, int id, int offset) {
|
||||
this.id = id;
|
||||
this.startOffset = offset;
|
||||
this.id = ++initialID;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.android.dx.io.ClassDef;
|
||||
|
||||
public class ClassNode extends AttrNode implements ILoadable {
|
||||
|
||||
private final static Logger LOG = LoggerFactory.getLogger(ClassNode.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ClassNode.class);
|
||||
|
||||
private final DexNode dex;
|
||||
private final ClassInfo clsInfo;
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.android.dx.merge.TypeList;
|
||||
|
||||
public class DexNode {
|
||||
|
||||
public final static int NO_INDEX = -1;
|
||||
public static final int NO_INDEX = -1;
|
||||
|
||||
private final RootNode root;
|
||||
private final DexBuffer dexBuf;
|
||||
|
||||
@@ -148,6 +148,7 @@ public class InsnNode extends AttrNode {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null) return false;
|
||||
if (hashCode() != obj.hashCode()) return false;
|
||||
if (!(obj instanceof InsnNode)) return false;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import jadx.dex.info.AccessInfo.AFType;
|
||||
import jadx.dex.info.ClassInfo;
|
||||
import jadx.dex.info.MethodInfo;
|
||||
import jadx.dex.instructions.GotoNode;
|
||||
import jadx.dex.instructions.IfNode;
|
||||
import jadx.dex.instructions.InsnDecoder;
|
||||
import jadx.dex.instructions.SwitchNode;
|
||||
import jadx.dex.instructions.args.ArgType;
|
||||
@@ -27,9 +28,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.android.dx.io.ClassData.Method;
|
||||
import com.android.dx.io.Code;
|
||||
import com.android.dx.io.Code.CatchHandler;
|
||||
@@ -37,8 +35,6 @@ import com.android.dx.io.Code.Try;
|
||||
|
||||
public class MethodNode extends AttrNode implements ILoadable {
|
||||
|
||||
private final static Logger LOG = LoggerFactory.getLogger(MethodNode.class);
|
||||
|
||||
private final MethodInfo mthInfo;
|
||||
private final ClassNode parentClass;
|
||||
private final AccessInfo accFlags;
|
||||
@@ -259,23 +255,24 @@ public class MethodNode extends AttrNode implements ILoadable {
|
||||
case SWITCH: {
|
||||
SwitchNode sw = (SwitchNode) insn;
|
||||
for (int target : sw.getTargets()) {
|
||||
insnByOffset[target].getAttributes().add(new JumpAttribute(offset, target));
|
||||
addJump(insnByOffset, offset, target);
|
||||
}
|
||||
// default case
|
||||
int next = InsnDecoder.getNextInsnOffset(insnByOffset, offset);
|
||||
if (next != -1)
|
||||
insnByOffset[next].getAttributes().add(new JumpAttribute(offset, next));
|
||||
addJump(insnByOffset, offset, next);
|
||||
break;
|
||||
}
|
||||
|
||||
case IF:
|
||||
int next = InsnDecoder.getNextInsnOffset(insnByOffset, offset);
|
||||
if (next != -1)
|
||||
insnByOffset[next].getAttributes().add(new JumpAttribute(offset, next));
|
||||
// no break
|
||||
addJump(insnByOffset, offset, next);
|
||||
addJump(insnByOffset, offset, ((IfNode) insn).getTarget());
|
||||
break;
|
||||
|
||||
case GOTO:
|
||||
int target = ((GotoNode) insn).getTarget();
|
||||
insnByOffset[target].getAttributes().add(new JumpAttribute(offset, target));
|
||||
addJump(insnByOffset, offset, ((GotoNode) insn).getTarget());
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -284,6 +281,10 @@ public class MethodNode extends AttrNode implements ILoadable {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addJump(InsnNode[] insnByOffset, int offset, int target) {
|
||||
insnByOffset[target].getAttributes().add(new JumpAttribute(offset, target));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String name = mthInfo.getName();
|
||||
if (name.equals(parentClass.getShortName()))
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RootNode {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(RootNode.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RootNode.class);
|
||||
|
||||
private final JadxArgs jadxArgs;
|
||||
|
||||
|
||||
@@ -15,15 +15,10 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.android.dx.io.DexBuffer.Section;
|
||||
|
||||
public class AnnotationsParser {
|
||||
|
||||
private final static Logger LOG = LoggerFactory.getLogger(AnnotationsParser.class);
|
||||
|
||||
private final DexNode dex;
|
||||
|
||||
public AnnotationsParser(ClassNode cls, int offset) throws DecodeException {
|
||||
@@ -74,7 +69,6 @@ public class AnnotationsParser {
|
||||
Section anSection = dex.openSection(section.readInt());
|
||||
Annotation a = readAnnotation(dex, anSection, true);
|
||||
list.add(a);
|
||||
// LOG.debug(" + " + a);
|
||||
}
|
||||
return new AnnotationsList(list);
|
||||
}
|
||||
|
||||
@@ -14,20 +14,20 @@ import com.android.dx.io.DexBuffer.Section;
|
||||
|
||||
public class DebugInfoParser {
|
||||
|
||||
private final static int DBG_END_SEQUENCE = 0x00;
|
||||
private final static int DBG_ADVANCE_PC = 0x01;
|
||||
private final static int DBG_ADVANCE_LINE = 0x02;
|
||||
private final static int DBG_START_LOCAL = 0x03;
|
||||
private final static int DBG_START_LOCAL_EXTENDED = 0x04;
|
||||
private final static int DBG_END_LOCAL = 0x05;
|
||||
private final static int DBG_RESTART_LOCAL = 0x06;
|
||||
private final static int DBG_SET_PROLOGUE_END = 0x07;
|
||||
private final static int DBG_SET_EPILOGUE_BEGIN = 0x08;
|
||||
private final static int DBG_SET_FILE = 0x09;
|
||||
private static final int DBG_END_SEQUENCE = 0x00;
|
||||
private static final int DBG_ADVANCE_PC = 0x01;
|
||||
private static final int DBG_ADVANCE_LINE = 0x02;
|
||||
private static final int DBG_START_LOCAL = 0x03;
|
||||
private static final int DBG_START_LOCAL_EXTENDED = 0x04;
|
||||
private static final int DBG_END_LOCAL = 0x05;
|
||||
private static final int DBG_RESTART_LOCAL = 0x06;
|
||||
private static final int DBG_SET_PROLOGUE_END = 0x07;
|
||||
private static final int DBG_SET_EPILOGUE_BEGIN = 0x08;
|
||||
private static final int DBG_SET_FILE = 0x09;
|
||||
|
||||
private final static int DBG_FIRST_SPECIAL = 0x0a; // the smallest special opcode
|
||||
private final static int DBG_LINE_BASE = -4; // the smallest line number increment
|
||||
private final static int DBG_LINE_RANGE = 15; // the number of line increments represented
|
||||
private static final int DBG_FIRST_SPECIAL = 0x0a; // the smallest special opcode
|
||||
private static final int DBG_LINE_BASE = -4; // the smallest line number increment
|
||||
private static final int DBG_LINE_RANGE = 15; // the number of line increments represented
|
||||
|
||||
private final MethodNode mth;
|
||||
private final Section section;
|
||||
|
||||
@@ -26,26 +26,30 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class BlockMakerVisitor extends AbstractVisitor {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(BlockMakerVisitor.class);
|
||||
|
||||
// leave these instructions alone in block node
|
||||
private final static Set<InsnType> separateInsns = EnumSet.of(
|
||||
private static final Set<InsnType> separateInsns = EnumSet.of(
|
||||
InsnType.IF,
|
||||
InsnType.SWITCH,
|
||||
InsnType.MONITOR_ENTER,
|
||||
InsnType.MONITOR_EXIT);
|
||||
|
||||
private static int nextBlockId;
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode mth) {
|
||||
if (mth.isNoCode())
|
||||
return;
|
||||
|
||||
mth.initBasicBlocks();
|
||||
BlockNode.initialID = 0;
|
||||
makeBasicBlocks(mth);
|
||||
BlockProcessingHelper.visit(mth);
|
||||
mth.finishBasicBlocks();
|
||||
}
|
||||
|
||||
private static void makeBasicBlocks(MethodNode mth) {
|
||||
nextBlockId = 0;
|
||||
|
||||
InsnNode prevInsn = null;
|
||||
Map<Integer, BlockNode> blocksMap = new HashMap<Integer, BlockNode>();
|
||||
@@ -179,10 +183,6 @@ public class BlockMakerVisitor extends AbstractVisitor {
|
||||
if (i > 100)
|
||||
throw new AssertionError("Can't fix method cfg: " + mth);
|
||||
}
|
||||
|
||||
BlockProcessingHelper.visit(mth);
|
||||
|
||||
mth.finishBasicBlocks();
|
||||
}
|
||||
|
||||
private static BlockNode getBlock(MethodNode mth, int offset, Map<Integer, BlockNode> blocksMap) {
|
||||
@@ -204,7 +204,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
|
||||
}
|
||||
|
||||
private static BlockNode startNewBlock(MethodNode mth, int offset) {
|
||||
BlockNode block = new BlockNode(mth, offset);
|
||||
BlockNode block = new BlockNode(mth, ++nextBlockId, offset);
|
||||
mth.getBasicBlocks().add(block);
|
||||
return block;
|
||||
}
|
||||
@@ -337,7 +337,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
// splice return block
|
||||
// splice return block if several precessors presents
|
||||
if (block.getAttributes().contains(AttributeFlag.RETURN)
|
||||
&& block.getPredecessors().size() > 1
|
||||
&& !block.getInstructions().get(0).getAttributes().contains(AttributeType.CATCH_BLOCK)) {
|
||||
@@ -377,7 +377,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void cleanDomTree(MethodNode mth) {
|
||||
private static void cleanDomTree(MethodNode mth) {
|
||||
for (BlockNode block : mth.getBasicBlocks()) {
|
||||
AttributesList attrs = block.getAttributes();
|
||||
attrs.remove(AttributeType.LOOP);
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CodeShrinker extends AbstractVisitor {
|
||||
|
||||
private final static Logger LOG = LoggerFactory.getLogger(CodeShrinker.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CodeShrinker.class);
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode mth) {
|
||||
@@ -186,12 +186,12 @@ public class CodeShrinker extends AbstractVisitor {
|
||||
rarg.wrapInstruction(ai);
|
||||
}
|
||||
// remove method args
|
||||
if (list.size() != 0 & args.size() != 0) {
|
||||
if (list.size() != 0 && args.size() != 0) {
|
||||
list.removeAll(args);
|
||||
}
|
||||
i++;
|
||||
if (i > 10000)
|
||||
throw new JadxRuntimeException("Can't inline arguments for: " + arg + " insn:" + assignInsn);
|
||||
throw new JadxRuntimeException("Can't inline arguments for: " + arg + " insn: " + assignInsn);
|
||||
} while (!list.isEmpty());
|
||||
|
||||
return arg.wrapInstruction(assignInsn);
|
||||
|
||||
@@ -104,7 +104,7 @@ public class EnumVisitor extends AbstractVisitor {
|
||||
continue;
|
||||
|
||||
RegisterArg nameArg = (RegisterArg) insn.getArg(0);
|
||||
InsnArg pos = insn.getArg(1);
|
||||
// InsnArg pos = insn.getArg(1);
|
||||
// TODO add check: pos == j
|
||||
String name = (String) nameArg.getConstValue();
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
|
||||
* (remove, replace, process exception handlers)
|
||||
*/
|
||||
public class ModVisitor extends AbstractVisitor {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(ModVisitor.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ModVisitor.class);
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode mth) {
|
||||
|
||||
@@ -27,8 +27,8 @@ import org.slf4j.LoggerFactory;
|
||||
* Extract blocks to separate try/catch region
|
||||
*/
|
||||
public class MarkTryCatchRegions extends AbstractRegionVisitor {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(MarkTryCatchRegions.class);
|
||||
private final static boolean DEBUG = false;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MarkTryCatchRegions.class);
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
static {
|
||||
if (DEBUG)
|
||||
|
||||
@@ -12,11 +12,7 @@ import jadx.utils.exceptions.JadxException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PostRegionVisitor extends AbstractVisitor {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(PostRegionVisitor.class);
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode mth) throws JadxException {
|
||||
@@ -24,10 +20,9 @@ public class PostRegionVisitor extends AbstractVisitor {
|
||||
return;
|
||||
|
||||
DepthRegionTraverser.traverse(mth, new MarkTryCatchRegions(mth), mth.getRegion());
|
||||
|
||||
DepthRegionTraverser.traverse(mth, new FinishRegions(), mth.getRegion());
|
||||
|
||||
// removeReturn(mth);
|
||||
removeReturn(mth);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ProcessVariables extends AbstractVisitor {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(ProcessVariables.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProcessVariables.class);
|
||||
|
||||
private static class Usage {
|
||||
private RegisterArg arg;
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RegionMaker {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(RegionMaker.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RegionMaker.class);
|
||||
|
||||
private final MethodNode mth;
|
||||
|
||||
@@ -247,7 +247,7 @@ public class RegionMaker {
|
||||
return out;
|
||||
}
|
||||
|
||||
private final static Set<BlockNode> cacheSet = new HashSet<BlockNode>();
|
||||
private static final Set<BlockNode> cacheSet = new HashSet<BlockNode>();
|
||||
|
||||
private BlockNode processMonitorEnter(IRegion curRegion, BlockNode block, InsnNode insn, RegionStack stack) {
|
||||
RegisterArg arg = (RegisterArg) insn.getArg(0);
|
||||
|
||||
@@ -12,8 +12,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class RegionStack {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(RegionStack.class);
|
||||
private final static boolean DEBUG = false;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RegionStack.class);
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
static {
|
||||
if (DEBUG)
|
||||
|
||||
@@ -5,11 +5,7 @@ import jadx.dex.nodes.InsnNode;
|
||||
import jadx.dex.nodes.MethodNode;
|
||||
import jadx.utils.ErrorsCounter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CheckTypeVisitor {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(CheckTypeVisitor.class);
|
||||
|
||||
public static void visit(MethodNode mth, InsnNode insn) {
|
||||
if (insn.getResult() != null) {
|
||||
@@ -28,7 +24,6 @@ public class CheckTypeVisitor {
|
||||
}
|
||||
|
||||
private static void error(String msg, MethodNode mth, InsnNode insn) {
|
||||
// LOG.warn(msg + ": " + insn + " " + insn.getMethod());
|
||||
ErrorsCounter.methodError(mth, msg + ": " + insn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,19 +166,6 @@ public class BlockUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean addPredcessorsUntil(Set<BlockNode> set, BlockNode from, BlockNode until) {
|
||||
set.add(from);
|
||||
for (BlockNode pred : from.getPredecessors()) {
|
||||
if (pred == until)
|
||||
return true;
|
||||
if (pred != until && !set.contains(pred)) {
|
||||
if (addPredcessorsUntil(set, pred, until))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPathExists(BlockNode start, BlockNode end) {
|
||||
if (start == end)
|
||||
return true;
|
||||
|
||||
@@ -12,9 +12,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ErrorsCounter {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(ErrorsCounter.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ErrorsCounter.class);
|
||||
|
||||
private final static Set<Object> errorNodes = new HashSet<Object>();
|
||||
private static final Set<Object> errorNodes = new HashSet<Object>();
|
||||
private static int errorsCount = 0;
|
||||
|
||||
public static int getErrorCount() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package jadx.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Iterator;
|
||||
@@ -39,19 +38,6 @@ public class Utils {
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public static boolean deleteFolder(File dir) {
|
||||
File[] files = dir.listFiles();
|
||||
if (files != null) {
|
||||
for (File f : files) {
|
||||
if (f.isDirectory())
|
||||
deleteFolder(f);
|
||||
else
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
return dir.delete();
|
||||
}
|
||||
|
||||
public static String getStackTrace(Throwable throwable) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw, true);
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
import com.android.dx.io.DexBuffer;
|
||||
|
||||
public class InputFile {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(InputFile.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(InputFile.class);
|
||||
|
||||
private final File file;
|
||||
private final DexBuffer dexBuf;
|
||||
|
||||
@@ -4,15 +4,15 @@ import java.util.Arrays;
|
||||
|
||||
public class TestFields extends AbstractTest {
|
||||
|
||||
private final static boolean fbz = false;
|
||||
private final static boolean fb = true;
|
||||
private final static int fi = 5;
|
||||
private final static int fiz = 0;
|
||||
private static final boolean fbz = false;
|
||||
private static final boolean fb = true;
|
||||
private static final int fi = 5;
|
||||
private static final int fiz = 0;
|
||||
|
||||
private final static String fstr = "final string";
|
||||
private static final String fstr = "final string";
|
||||
|
||||
private final static double fd = 3.14;
|
||||
private final static double[] fda = new double[] { 3.14, 2.7 };
|
||||
private static final double fd = 3.14;
|
||||
private static final double[] fda = new double[] { 3.14, 2.7 };
|
||||
|
||||
private static int si = 5;
|
||||
|
||||
|
||||
@@ -62,11 +62,12 @@ public class TypeMergeTest extends TestCase {
|
||||
|
||||
private void merge(ArgType t1, ArgType t2, ArgType exp) {
|
||||
ArgType res = ArgType.merge(t1, t2);
|
||||
String msg = format(t1, t2, exp, res);
|
||||
if (exp == null) {
|
||||
assertNull("Incorrect accept: " + format(t1, t2, exp, res), res);
|
||||
assertNull("Incorrect accept: " + msg, res);
|
||||
} else {
|
||||
assertNotNull("Incorrect reject: " + format(t1, t2, exp, res), res);
|
||||
assertTrue("Incorrect result: " + format(t1, t2, exp, res), exp.equals(res));
|
||||
assertNotNull("Incorrect reject: " + msg, res);
|
||||
assertTrue("Incorrect result: " + msg, exp.equals(res));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user