Commit 4e284c4c authored by Skylot's avatar Skylot

Use chars instead strings, code refactoring

parent c363bea5
...@@ -55,7 +55,7 @@ public class ClassGen { ...@@ -55,7 +55,7 @@ public class ClassGen {
CodeWriter clsCode = new CodeWriter(); CodeWriter clsCode = new CodeWriter();
if (!"".equals(cls.getPackage())) { if (!"".equals(cls.getPackage())) {
clsCode.add("package ").add(cls.getPackage()).add(";"); clsCode.add("package ").add(cls.getPackage()).add(';');
clsCode.endl(); clsCode.endl();
} }
...@@ -66,7 +66,7 @@ public class ClassGen { ...@@ -66,7 +66,7 @@ public class ClassGen {
Collections.sort(sortImports); Collections.sort(sortImports);
for (String imp : sortImports) { for (String imp : sortImports) {
clsCode.startLine("import ").add(imp).add(";"); clsCode.startLine("import ").add(imp).add(';');
} }
clsCode.endl(); clsCode.endl();
...@@ -165,7 +165,7 @@ public class ClassGen { ...@@ -165,7 +165,7 @@ public class ClassGen {
} }
public void makeClassBody(CodeWriter clsCode) throws CodegenException { public void makeClassBody(CodeWriter clsCode) throws CodegenException {
clsCode.add("{"); clsCode.add('{');
CodeWriter mthsCode = makeMethods(clsCode, cls.getMethods()); CodeWriter mthsCode = makeMethods(clsCode, cls.getMethods());
clsCode.add(makeFields(clsCode, cls, cls.getFields())); clsCode.add(makeFields(clsCode, cls, cls.getFields()));
...@@ -174,7 +174,7 @@ public class ClassGen { ...@@ -174,7 +174,7 @@ public class ClassGen {
clsCode.add(makeInnerClasses(cls, clsCode.getIndent())); clsCode.add(makeInnerClasses(cls, clsCode.getIndent()));
} }
clsCode.add(mthsCode); clsCode.add(mthsCode);
clsCode.startLine("}"); clsCode.startLine('}');
} }
private CodeWriter makeInnerClasses(ClassNode cls2, int indent) throws CodegenException { private CodeWriter makeInnerClasses(ClassNode cls2, int indent) throws CodegenException {
...@@ -190,7 +190,7 @@ public class ClassGen { ...@@ -190,7 +190,7 @@ public class ClassGen {
return innerClsCode; return innerClsCode;
} }
private CodeWriter makeMethods(CodeWriter clsCode, List<MethodNode> mthList) throws CodegenException { private CodeWriter makeMethods(CodeWriter clsCode, List<MethodNode> mthList) {
CodeWriter code = new CodeWriter(clsCode.getIndent() + 1); CodeWriter code = new CodeWriter(clsCode.getIndent() + 1);
for (Iterator<MethodNode> it = mthList.iterator(); it.hasNext();) { for (Iterator<MethodNode> it = mthList.iterator(); it.hasNext();) {
MethodNode mth = it.next(); MethodNode mth = it.next();
...@@ -208,7 +208,7 @@ public class ClassGen { ...@@ -208,7 +208,7 @@ public class ClassGen {
code.add(" default ").add(v); code.add(" default ").add(v);
} }
} }
code.add(";"); code.add(';');
} else { } else {
if (mth.isNoCode()) if (mth.isNoCode())
continue; continue;
...@@ -217,7 +217,7 @@ public class ClassGen { ...@@ -217,7 +217,7 @@ public class ClassGen {
mthGen.addDefinition(code); mthGen.addDefinition(code);
code.add(" {"); code.add(" {");
code.add(mthGen.makeInstructions(code.getIndent())); code.add(mthGen.makeInstructions(code.getIndent()));
code.startLine("}"); code.startLine('}');
} }
} catch (Throwable e) { } catch (Throwable e) {
String msg = ErrorsCounter.methodError(mth, "Method generation error", e); String msg = ErrorsCounter.methodError(mth, "Method generation error", e);
...@@ -268,7 +268,7 @@ public class ClassGen { ...@@ -268,7 +268,7 @@ public class ClassGen {
annotationGen.addForField(code, f); annotationGen.addForField(code, f);
code.startLine(f.getAccessFlags().makeString()); code.startLine(f.getAccessFlags().makeString());
code.add(TypeGen.translate(this, f.getType())); code.add(TypeGen.translate(this, f.getType()));
code.add(" "); code.add(' ');
code.add(f.getName()); code.add(f.getName());
FieldValueAttr fv = (FieldValueAttr) f.getAttributes().get(AttributeType.FIELD_VALUE); FieldValueAttr fv = (FieldValueAttr) f.getAttributes().get(AttributeType.FIELD_VALUE);
if (fv != null) { if (fv != null) {
...@@ -279,7 +279,7 @@ public class ClassGen { ...@@ -279,7 +279,7 @@ public class ClassGen {
code.add(annotationGen.encValueToString(fv.getValue())); code.add(annotationGen.encValueToString(fv.getValue()));
} }
} }
code.add(";"); code.add(';');
} }
if (fields.size() != 0) if (fields.size() != 0)
code.endl(); code.endl();
...@@ -299,7 +299,7 @@ public class ClassGen { ...@@ -299,7 +299,7 @@ public class ClassGen {
if (generics != null) { if (generics != null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(baseClass); sb.append(baseClass);
sb.append("<"); sb.append('<');
int len = generics.length; int len = generics.length;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (i != 0) { if (i != 0) {
...@@ -311,7 +311,7 @@ public class ClassGen { ...@@ -311,7 +311,7 @@ public class ClassGen {
else else
sb.append('?'); sb.append('?');
} }
sb.append(">"); sb.append('>');
return sb.toString(); return sb.toString();
} else { } else {
return baseClass; return baseClass;
......
...@@ -13,7 +13,7 @@ public class CodeWriter { ...@@ -13,7 +13,7 @@ public class CodeWriter {
private static final int MAX_FILENAME_LENGTH = 128; private static final int MAX_FILENAME_LENGTH = 128;
public static final String NL = System.getProperty("line.separator"); public static final String NL = System.getProperty("line.separator");
public static final String INDENT = "\t"; private static final String INDENT = "\t";
private StringBuilder buf = new StringBuilder(); private StringBuilder buf = new StringBuilder();
private String indentStr; private String indentStr;
......
...@@ -84,20 +84,15 @@ public class InsnGen { ...@@ -84,20 +84,15 @@ public class InsnGen {
} }
public String assignVar(InsnNode insn) { public String assignVar(InsnNode insn) {
try { RegisterArg arg = insn.getResult();
RegisterArg arg = insn.getResult(); if (insn.getAttributes().contains(AttributeType.DECLARE_VARIABLE)) {
if (insn.getAttributes().contains(AttributeType.DECLARE_VARIABLE)) { return declareVar(arg);
return declareVar(arg); } else {
} else { return mgen.makeArgName(arg);
return mgen.makeArgName(arg);
}
} catch (CodegenException e) {
LOG.error("Assign var codegen error", e);
return "<error>";
} }
} }
public String declareVar(RegisterArg arg) throws CodegenException { public String declareVar(RegisterArg arg) {
return useType(arg.getType()) + " " + mgen.assignArg(arg); return useType(arg.getType()) + " " + mgen.assignArg(arg);
} }
...@@ -237,8 +232,8 @@ public class InsnGen { ...@@ -237,8 +232,8 @@ public class InsnGen {
break; break;
case INSTANCE_OF: case INSTANCE_OF:
code.add("(").add(arg(insn, 0)).add(" instanceof ") code.add('(').add(arg(insn, 0)).add(" instanceof ")
.add(useType((ArgType) ((IndexInsnNode) insn).getIndex())).add(")"); .add(useType((ArgType) ((IndexInsnNode) insn).getIndex())).add(')');
break; break;
case CONSTRUCTOR: case CONSTRUCTOR:
...@@ -296,7 +291,7 @@ public class InsnGen { ...@@ -296,7 +291,7 @@ public class InsnGen {
case MONITOR_ENTER: case MONITOR_ENTER:
if (isFallback()) { if (isFallback()) {
code.add("monitor-enter(").add(arg(insn.getArg(0))).add(")"); code.add("monitor-enter(").add(arg(insn.getArg(0))).add(')');
} else { } else {
state.add(InsnGenState.SKIP); state.add(InsnGenState.SKIP);
} }
...@@ -304,7 +299,7 @@ public class InsnGen { ...@@ -304,7 +299,7 @@ public class InsnGen {
case MONITOR_EXIT: case MONITOR_EXIT:
if (isFallback()) { if (isFallback()) {
code.add("monitor-exit(").add(arg(insn.getArg(0))).add(")"); code.add("monitor-exit(").add(arg(insn.getArg(0))).add(')');
} else { } else {
state.add(InsnGenState.SKIP); state.add(InsnGenState.SKIP);
} }
...@@ -358,7 +353,7 @@ public class InsnGen { ...@@ -358,7 +353,7 @@ public class InsnGen {
} }
code.startLine("default: goto " + MethodGen.getLabelName(sw.getDefaultCaseOffset()) + ";"); code.startLine("default: goto " + MethodGen.getLabelName(sw.getDefaultCaseOffset()) + ";");
code.decIndent(); code.decIndent();
code.startLine("}"); code.startLine('}');
state.add(InsnGenState.NO_SEMICOLON); state.add(InsnGenState.NO_SEMICOLON);
break; break;
...@@ -376,13 +371,13 @@ public class InsnGen { ...@@ -376,13 +371,13 @@ public class InsnGen {
private void filledNewArray(InsnNode insn, CodeWriter code) throws CodegenException { private void filledNewArray(InsnNode insn, CodeWriter code) throws CodegenException {
int c = insn.getArgsCount(); int c = insn.getArgsCount();
code.add("new ").add(useType(insn.getResult().getType())); code.add("new ").add(useType(insn.getResult().getType()));
code.add("{"); code.add('{');
for (int i = 0; i < c; i++) { for (int i = 0; i < c; i++) {
code.add(arg(insn, i)); code.add(arg(insn, i));
if (i + 1 < c) if (i + 1 < c)
code.add(", "); code.add(", ");
} }
code.add("}"); code.add('}');
} }
private void fillArray(FillArrayOp insn, CodeWriter code) throws CodegenException { private void fillArray(FillArrayOp insn, CodeWriter code) throws CodegenException {
......
...@@ -133,7 +133,7 @@ public class MethodGen { ...@@ -133,7 +133,7 @@ public class MethodGen {
} else { } else {
argsCode.add(TypeGen.translate(classGen, arg.getType())); argsCode.add(TypeGen.translate(classGen, arg.getType()));
} }
argsCode.add(" "); argsCode.add(' ');
argsCode.add(makeArgName(arg)); argsCode.add(makeArgName(arg));
i++; i++;
...@@ -253,7 +253,7 @@ public class MethodGen { ...@@ -253,7 +253,7 @@ public class MethodGen {
makeFallbackMethod(code, mth); makeFallbackMethod(code, mth);
code.decIndent(); code.decIndent();
code.startLine("}"); code.startLine('}');
code.startLine("*/"); code.startLine("*/");
} }
......
...@@ -254,7 +254,7 @@ public class RegionGen extends InsnGen { ...@@ -254,7 +254,7 @@ public class RegionGen extends InsnGen {
code.startLine("} catch ("); code.startLine("} catch (");
code.add(handler.isCatchAll() ? "Throwable" : useClass(handler.getCatchType())); code.add(handler.isCatchAll() ? "Throwable" : useClass(handler.getCatchType()));
code.add(' '); code.add(' ');
code.add(arg(handler.getArg())); code.add(mgen.assignArg(handler.getArg()));
code.add(") {"); code.add(") {");
makeRegionIndent(code, region); makeRegionIndent(code, region);
} }
......
...@@ -22,6 +22,7 @@ public class TypeGen { ...@@ -22,6 +22,7 @@ public class TypeGen {
return stype.getLongName(); return stype.getLongName();
} }
@Deprecated
public static String shortString(ArgType type) { public static String shortString(ArgType type) {
final PrimitiveType stype = type.getPrimitiveType(); final PrimitiveType stype = type.getPrimitiveType();
if (stype == null) if (stype == null)
......
...@@ -16,7 +16,7 @@ public class FieldInfo { ...@@ -16,7 +16,7 @@ public class FieldInfo {
return new FieldInfo(dex, index); return new FieldInfo(dex, index);
} }
protected FieldInfo(DexNode dex, int ind) { private FieldInfo(DexNode dex, int ind) {
FieldId field = dex.getFieldId(ind); FieldId field = dex.getFieldId(ind);
this.name = dex.getString(field.getNameIndex()); this.name = dex.getString(field.getNameIndex());
this.type = dex.getType(field.getTypeIndex()); this.type = dex.getType(field.getTypeIndex());
......
...@@ -5,7 +5,7 @@ import jadx.utils.InsnUtils; ...@@ -5,7 +5,7 @@ import jadx.utils.InsnUtils;
public class IndexInsnNode extends InsnNode { public class IndexInsnNode extends InsnNode {
protected final Object index; private final Object index;
public IndexInsnNode(InsnType type, Object index, int argCount) { public IndexInsnNode(InsnType type, Object index, int argCount) {
super(type, argCount); super(type, argCount);
......
...@@ -587,10 +587,7 @@ public abstract class ArgType { ...@@ -587,10 +587,7 @@ public abstract class ArgType {
return false; return false;
} }
// TODO: don't use toString // TODO: don't use toString
if (!toString().equals(obj.toString())) { return toString().equals(obj.toString());
return false; }
}
return true;
}
} }
...@@ -72,4 +72,8 @@ public abstract class InsnArg extends Typed { ...@@ -72,4 +72,8 @@ public abstract class InsnArg extends Typed {
return false; return false;
} }
public int getRegNum() {
throw new UnsupportedOperationException("Must be called from RegisterArg");
}
} }
...@@ -17,6 +17,7 @@ public class RegisterArg extends InsnArg { ...@@ -17,6 +17,7 @@ public class RegisterArg extends InsnArg {
this.regNum = rn; this.regNum = rn;
} }
@Override
public int getRegNum() { public int getRegNum() {
return regNum; return regNum;
} }
......
...@@ -57,7 +57,7 @@ public class TypedVar { ...@@ -57,7 +57,7 @@ public class TypedVar {
@Override @Override
public int hashCode() { public int hashCode() {
return type.hashCode() * 31 + ((name == null) ? 0 : name.hashCode()); return type.hashCode() * 31 + (name == null ? 0 : name.hashCode());
} }
@Override @Override
...@@ -66,12 +66,12 @@ public class TypedVar { ...@@ -66,12 +66,12 @@ public class TypedVar {
if (obj == null) return false; if (obj == null) return false;
if (getClass() != obj.getClass()) return false; if (getClass() != obj.getClass()) return false;
TypedVar other = (TypedVar) obj; TypedVar other = (TypedVar) obj;
if (!type.equals(other.type)) return false;
if (name == null) { if (name == null) {
if (other.name != null) return false; if (other.name != null) return false;
} else if (!name.equals(other.name)) return false; } else if (!name.equals(other.name)) {
if (type == null) { return false;
if (other.type != null) return false; }
} else if (!type.equals(other.type)) return false;
return true; return true;
} }
......
...@@ -30,7 +30,7 @@ public class DexNode { ...@@ -30,7 +30,7 @@ public class DexNode {
private final List<ClassNode> classes = new ArrayList<ClassNode>(); private final List<ClassNode> classes = new ArrayList<ClassNode>();
private final String[] strings; private final String[] strings;
public DexNode(RootNode root, InputFile input) throws IOException, DecodeException { public DexNode(RootNode root, InputFile input) {
this.root = root; this.root = root;
this.dexBuf = input.getDexBuffer(); this.dexBuf = input.getDexBuffer();
......
...@@ -71,7 +71,7 @@ public class InsnNode extends AttrNode { ...@@ -71,7 +71,7 @@ public class InsnNode extends AttrNode {
public boolean containsArg(RegisterArg arg) { public boolean containsArg(RegisterArg arg) {
for (InsnArg a : arguments) { for (InsnArg a : arguments) {
if (a == arg || (a.isRegister() && ((RegisterArg) a).getRegNum() == arg.getRegNum())) if (a == arg || (a.isRegister() && a.getRegNum() == arg.getRegNum()))
return true; return true;
} }
return false; return false;
......
...@@ -100,8 +100,7 @@ public class MethodNode extends AttrNode implements ILoadable { ...@@ -100,8 +100,7 @@ public class MethodNode extends AttrNode implements ILoadable {
initJumps(insnByOffset); initJumps(insnByOffset);
if (mthCode.getDebugInfoOffset() > 0) { if (mthCode.getDebugInfoOffset() > 0) {
DebugInfoParser debugInfo = new DebugInfoParser(this, mthCode.getDebugInfoOffset()); (new DebugInfoParser(this, mthCode.getDebugInfoOffset(), insnByOffset)).process();
debugInfo.process(insnByOffset);
} }
} catch (Exception e) { } catch (Exception e) {
throw new DecodeException(this, "Load method exception", e); throw new DecodeException(this, "Load method exception", e);
......
...@@ -30,6 +30,7 @@ public class BlockMakerVisitor extends AbstractVisitor { ...@@ -30,6 +30,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
// leave these instructions alone in block node // leave these instructions alone in block node
private static final Set<InsnType> separateInsns = EnumSet.of( private static final Set<InsnType> separateInsns = EnumSet.of(
InsnType.RETURN,
InsnType.IF, InsnType.IF,
InsnType.SWITCH, InsnType.SWITCH,
InsnType.MONITOR_ENTER, InsnType.MONITOR_ENTER,
...@@ -165,12 +166,8 @@ public class BlockMakerVisitor extends AbstractVisitor { ...@@ -165,12 +166,8 @@ public class BlockMakerVisitor extends AbstractVisitor {
} }
} }
} }
computeDominators(mth); computeDominators(mth);
markReturnBlocks(mth);
for (BlockNode block : mth.getBasicBlocks()) {
markReturnBlocks(mth, block);
}
int i = 0; int i = 0;
while (modifyBlocksTree(mth)) { while (modifyBlocksTree(mth)) {
...@@ -178,6 +175,7 @@ public class BlockMakerVisitor extends AbstractVisitor { ...@@ -178,6 +175,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
cleanDomTree(mth); cleanDomTree(mth);
// recalculate dominators tree // recalculate dominators tree
computeDominators(mth); computeDominators(mth);
markReturnBlocks(mth);
i++; i++;
if (i > 100) if (i > 100)
...@@ -273,7 +271,7 @@ public class BlockMakerVisitor extends AbstractVisitor { ...@@ -273,7 +271,7 @@ public class BlockMakerVisitor extends AbstractVisitor {
BlockNode idom = mth.getBasicBlocks().get(id); BlockNode idom = mth.getBasicBlocks().get(id);
block.setIDom(idom); block.setIDom(idom);
idom.getDominatesOn().add(block); idom.getDominatesOn().add(block);
} else if (block != entryBlock) { } else {
throw new JadxRuntimeException("Can't find immediate dominator for block " + block throw new JadxRuntimeException("Can't find immediate dominator for block " + block
+ " in " + bs + " prec:" + block.getPredecessors()); + " in " + bs + " prec:" + block.getPredecessors());
} }
...@@ -284,9 +282,8 @@ public class BlockMakerVisitor extends AbstractVisitor { ...@@ -284,9 +282,8 @@ public class BlockMakerVisitor extends AbstractVisitor {
private static void markLoops(MethodNode mth) { private static void markLoops(MethodNode mth) {
for (BlockNode block : mth.getBasicBlocks()) { for (BlockNode block : mth.getBasicBlocks()) {
for (BlockNode succ : block.getSuccessors()) { for (BlockNode succ : block.getSuccessors()) {
// Every successor that dominates its predecessor // Every successor that dominates its predecessor is a header of a loop,
// must be the header of a loop. // block -> succ is a back edge.
// That is, block -> succ is a back edge.
if (block.getDoms().get(succ.getId())) { if (block.getDoms().get(succ.getId())) {
succ.getAttributes().add(AttributeFlag.LOOP_START); succ.getAttributes().add(AttributeFlag.LOOP_START);
block.getAttributes().add(AttributeFlag.LOOP_END); block.getAttributes().add(AttributeFlag.LOOP_END);
...@@ -299,10 +296,12 @@ public class BlockMakerVisitor extends AbstractVisitor { ...@@ -299,10 +296,12 @@ public class BlockMakerVisitor extends AbstractVisitor {
} }
} }
private static void markReturnBlocks(MethodNode mth, BlockNode block) { private static void markReturnBlocks(MethodNode mth) {
if (block.getInstructions().size() == 1) { for (BlockNode block : mth.getBasicBlocks()) {
if (block.getInstructions().get(0).getType() == InsnType.RETURN) if (block.getInstructions().size() == 1) {
block.getAttributes().add(AttributeFlag.RETURN); if (block.getInstructions().get(0).getType() == InsnType.RETURN)
block.getAttributes().add(AttributeFlag.RETURN);
}
} }
} }
......
...@@ -45,9 +45,10 @@ public class BlockProcessingHelper { ...@@ -45,9 +45,10 @@ public class BlockProcessingHelper {
// set correct type for 'move-exception' operation // set correct type for 'move-exception' operation
RegisterArg excArg = me.getResult(); RegisterArg excArg = me.getResult();
if (excHandler.isCatchAll()) if (excHandler.isCatchAll())
excArg.getTypedVar().merge(ArgType.THROWABLE); excArg.getTypedVar().forceSetType(ArgType.THROWABLE);
else else
excArg.getTypedVar().merge(excHandler.getCatchType().getType()); excArg.getTypedVar().forceSetType(excHandler.getCatchType().getType());
// excArg.getTypedVar().merge(excHandler.getCatchType().getType());
excHandler.setArg(excArg); excHandler.setArg(excArg);
block.getAttributes().add(handlerAttr); block.getAttributes().add(handlerAttr);
......
...@@ -34,7 +34,7 @@ public class ConstInlinerVisitor extends AbstractVisitor { ...@@ -34,7 +34,7 @@ public class ConstInlinerVisitor extends AbstractVisitor {
} }
} }
public static boolean checkInsn(MethodNode mth, BlockNode block, InsnNode insn) { private static boolean checkInsn(MethodNode mth, BlockNode block, InsnNode insn) {
if (insn.getType() == InsnType.CONST) { if (insn.getType() == InsnType.CONST) {
if (insn.getArgsCount() == 1 if (insn.getArgsCount() == 1
&& insn.getArg(0).isLiteral() && insn.getArg(0).isLiteral()
......
...@@ -75,7 +75,7 @@ public class DotGraphVisitor extends AbstractVisitor { ...@@ -75,7 +75,7 @@ public class DotGraphVisitor extends AbstractVisitor {
dot.add(conn); dot.add(conn);
dot.startLine("}"); dot.startLine('}');
dot.startLine(); dot.startLine();
String fileName = Utils.escape(mth.getMethodInfo().getShortId()) String fileName = Utils.escape(mth.getMethodInfo().getShortId())
...@@ -99,7 +99,7 @@ public class DotGraphVisitor extends AbstractVisitor { ...@@ -99,7 +99,7 @@ public class DotGraphVisitor extends AbstractVisitor {
processRegion(mth, c, dot, conn); processRegion(mth, c, dot, conn);
} }
dot.startLine("}"); dot.startLine('}');
} else if (region instanceof BlockNode) { } else if (region instanceof BlockNode) {
processBlock(mth, (BlockNode) region, dot, conn); processBlock(mth, (BlockNode) region, dot, conn);
} }
......
...@@ -40,8 +40,7 @@ public class MethodInlinerVisitor extends AbstractVisitor { ...@@ -40,8 +40,7 @@ public class MethodInlinerVisitor extends AbstractVisitor {
if (block.getInstructions().size() == 1) { if (block.getInstructions().size() == 1) {
InsnNode insn = block.getInstructions().get(0); InsnNode insn = block.getInstructions().get(0);
addInlineAttr(mth, insn); addInlineAttr(mth, insn);
return; }
}
} }
} }
} }
......
...@@ -39,7 +39,7 @@ public class BlockUtils { ...@@ -39,7 +39,7 @@ public class BlockUtils {
return list.get(1); return list.get(1);
} }
public static List<BlockNode> cleanBlockList(List<BlockNode> list) { private static List<BlockNode> cleanBlockList(List<BlockNode> list) {
List<BlockNode> ret = new ArrayList<BlockNode>(list.size()); List<BlockNode> ret = new ArrayList<BlockNode>(list.size());
for (BlockNode block : list) { for (BlockNode block : list) {
if (!block.getAttributes().contains(AttributeType.EXC_HANDLER)) if (!block.getAttributes().contains(AttributeType.EXC_HANDLER))
...@@ -52,11 +52,8 @@ public class BlockUtils { ...@@ -52,11 +52,8 @@ public class BlockUtils {
if (from.getCleanSuccessors().contains(to)) if (from.getCleanSuccessors().contains(to))
return false; // already checked return false; // already checked
if (!from.getSuccessors().contains(to)) return from.getSuccessors().contains(to);
return false; // not even successor }
return true;
}
/** /**
* Remove exception handlers from block nodes bitset * Remove exception handlers from block nodes bitset
......
...@@ -22,7 +22,7 @@ public class StringUtils { ...@@ -22,7 +22,7 @@ public class StringUtils {
return '\'' + res.toString() + '\''; return '\'' + res.toString() + '\'';
} }
public static void processChar(int c, StringBuilder res) { private static void processChar(int c, StringBuilder res) {
switch (c) { switch (c) {
case '\n': case '\n':
res.append("\\n"); res.append("\\n");
......
...@@ -126,7 +126,7 @@ public class Utils { ...@@ -126,7 +126,7 @@ public class Utils {
public static String getJadxVersion() { public static String getJadxVersion() {
try { try {
Enumeration<URL> resources = Enumeration<URL> resources =
new Utils().getClass().getClassLoader().getResources("META-INF/MANIFEST.MF"); Utils.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (resources.hasMoreElements()) { while (resources.hasMoreElements()) {
Manifest manifest = new Manifest(resources.nextElement().openStream()); Manifest manifest = new Manifest(resources.nextElement().openStream());
String ver = manifest.getMainAttributes().getValue("jadx-version"); String ver = manifest.getMainAttributes().getValue("jadx-version");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment