Commit 73dd55ea authored by Skylot's avatar Skylot

core: fix code style issues

parent b5a9389c
...@@ -22,7 +22,7 @@ public final class ProcessClass { ...@@ -22,7 +22,7 @@ public final class ProcessClass {
DepthTraversal.visit(visitor, cls); DepthTraversal.visit(visitor, cls);
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Class process exception: " + cls, e); LOG.error("Class process exception: {}", cls, e);
} finally { } finally {
cls.unload(); cls.unload();
} }
......
...@@ -96,7 +96,7 @@ public class ClsSet { ...@@ -96,7 +96,7 @@ public class ClsSet {
private static NClass getCls(String fullName, Map<String, NClass> names) { private static NClass getCls(String fullName, Map<String, NClass> names) {
NClass id = names.get(fullName); NClass id = names.get(fullName);
if (id == null && !names.containsKey(fullName)) { if (id == null && !names.containsKey(fullName)) {
LOG.warn("Class not found: " + fullName); LOG.warn("Class not found: {}", fullName);
} }
return id; return id;
} }
...@@ -132,7 +132,7 @@ public class ClsSet { ...@@ -132,7 +132,7 @@ public class ClsSet {
out.writeBytes(JADX_CLS_SET_HEADER); out.writeBytes(JADX_CLS_SET_HEADER);
out.writeByte(VERSION); out.writeByte(VERSION);
LOG.info("Classes count: " + classes.length); LOG.info("Classes count: {}", classes.length);
out.writeInt(classes.length); out.writeInt(classes.length);
for (NClass cls : classes) { for (NClass cls : classes) {
writeString(out, cls.getName()); writeString(out, cls.getName());
......
...@@ -39,7 +39,7 @@ public class ConvertToClsSet { ...@@ -39,7 +39,7 @@ public class ConvertToClsSet {
} }
} }
for (InputFile inputFile : inputFiles) { for (InputFile inputFile : inputFiles) {
LOG.info("Loaded: " + inputFile.getFile()); LOG.info("Loaded: {}", inputFile.getFile());
} }
RootNode root = new RootNode(); RootNode root = new RootNode();
...@@ -48,7 +48,7 @@ public class ConvertToClsSet { ...@@ -48,7 +48,7 @@ public class ConvertToClsSet {
ClsSet set = new ClsSet(); ClsSet set = new ClsSet();
set.load(root); set.load(root);
set.save(output); set.save(output);
LOG.info("Output: " + output); LOG.info("Output: {}", output);
LOG.info("done"); LOG.info("done");
} }
......
...@@ -150,9 +150,9 @@ public class AnnotationGen { ...@@ -150,9 +150,9 @@ public class AnnotationGen {
// must be a static field // must be a static field
FieldInfo field = (FieldInfo) val; FieldInfo field = (FieldInfo) val;
InsnGen.makeStaticFieldAccess(code, field, classGen); InsnGen.makeStaticFieldAccess(code, field, classGen);
} else if (val instanceof List) { } else if (val instanceof Iterable) {
code.add('{'); code.add('{');
Iterator<?> it = ((List) val).iterator(); Iterator<?> it = ((Iterable) val).iterator();
while (it.hasNext()) { while (it.hasNext()) {
Object obj = it.next(); Object obj = it.next();
encodeValue(code, obj); encodeValue(code, obj);
......
...@@ -25,7 +25,7 @@ import jadx.core.dex.instructions.args.FieldArg; ...@@ -25,7 +25,7 @@ import jadx.core.dex.instructions.args.FieldArg;
import jadx.core.dex.instructions.args.InsnArg; import jadx.core.dex.instructions.args.InsnArg;
import jadx.core.dex.instructions.args.InsnWrapArg; import jadx.core.dex.instructions.args.InsnWrapArg;
import jadx.core.dex.instructions.args.LiteralArg; import jadx.core.dex.instructions.args.LiteralArg;
import jadx.core.dex.instructions.args.NamedArg; import jadx.core.dex.instructions.args.Named;
import jadx.core.dex.instructions.args.RegisterArg; import jadx.core.dex.instructions.args.RegisterArg;
import jadx.core.dex.instructions.mods.ConstructorInsn; import jadx.core.dex.instructions.mods.ConstructorInsn;
import jadx.core.dex.instructions.mods.TernaryInsn; import jadx.core.dex.instructions.mods.TernaryInsn;
...@@ -98,7 +98,7 @@ public class InsnGen { ...@@ -98,7 +98,7 @@ public class InsnGen {
Flags flag = wrap ? Flags.BODY_ONLY : Flags.BODY_ONLY_NOWRAP; Flags flag = wrap ? Flags.BODY_ONLY : Flags.BODY_ONLY_NOWRAP;
makeInsn(((InsnWrapArg) arg).getWrapInsn(), code, flag); makeInsn(((InsnWrapArg) arg).getWrapInsn(), code, flag);
} else if (arg.isNamed()) { } else if (arg.isNamed()) {
code.add(((NamedArg) arg).getName()); code.add(((Named) arg).getName());
} else if (arg.isField()) { } else if (arg.isField()) {
FieldArg f = (FieldArg) arg; FieldArg f = (FieldArg) arg;
if (f.isStatic()) { if (f.isStatic()) {
......
...@@ -292,7 +292,7 @@ public class RegionGen extends InsnGen { ...@@ -292,7 +292,7 @@ public class RegionGen extends InsnGen {
makeCatchBlock(code, handler); makeCatchBlock(code, handler);
} else { } else {
if (allHandler != null) { if (allHandler != null) {
LOG.warn("Several 'all' handlers in try/catch block in " + mth); LOG.warn("Several 'all' handlers in try/catch block in {}", mth);
} }
allHandler = handler; allHandler = handler;
} }
......
...@@ -15,6 +15,7 @@ public class TypeImmutableArg extends RegisterArg { ...@@ -15,6 +15,7 @@ public class TypeImmutableArg extends RegisterArg {
@Override @Override
public void setType(ArgType type) { public void setType(ArgType type) {
// not allowed
} }
public void markAsThis() { public void markAsThis() {
......
...@@ -132,7 +132,7 @@ public class ClassNode extends LineAttrNode implements ILoadable { ...@@ -132,7 +132,7 @@ public class ClassNode extends LineAttrNode implements ILoadable {
try { try {
new AnnotationsParser(this).parse(offset); new AnnotationsParser(this).parse(offset);
} catch (DecodeException e) { } catch (DecodeException e) {
LOG.error("Error parsing annotations in " + this, e); LOG.error("Error parsing annotations in {}", this, e);
} }
} }
} }
...@@ -184,7 +184,7 @@ public class ClassNode extends LineAttrNode implements ILoadable { ...@@ -184,7 +184,7 @@ public class ClassNode extends LineAttrNode implements ILoadable {
} }
} }
} catch (JadxRuntimeException e) { } catch (JadxRuntimeException e) {
LOG.error("Class signature parse error: " + this, e); LOG.error("Class signature parse error: {}", this, e);
} }
} }
...@@ -198,7 +198,7 @@ public class ClassNode extends LineAttrNode implements ILoadable { ...@@ -198,7 +198,7 @@ public class ClassNode extends LineAttrNode implements ILoadable {
field.setType(gType); field.setType(gType);
} }
} catch (JadxRuntimeException e) { } catch (JadxRuntimeException e) {
LOG.error("Field signature parse error: " + field, e); LOG.error("Field signature parse error: {}", field, e);
} }
} }
} }
......
...@@ -147,8 +147,7 @@ public class MethodNode extends LineAttrNode implements ILoadable { ...@@ -147,8 +147,7 @@ public class MethodNode extends LineAttrNode implements ILoadable {
return false; return false;
} }
if (!mthInfo.isConstructor()) { if (!mthInfo.isConstructor()) {
LOG.warn("Wrong signature parse result: " + sp + " -> " + argsTypes LOG.warn("Wrong signature parse result: {} -> {}, not generic version: {}", sp, argsTypes, mthArgs);
+ ", not generic version: " + mthArgs);
return false; return false;
} else if (getParentClass().getAccessFlags().isEnum()) { } else if (getParentClass().getAccessFlags().isEnum()) {
// TODO: // TODO:
...@@ -164,7 +163,7 @@ public class MethodNode extends LineAttrNode implements ILoadable { ...@@ -164,7 +163,7 @@ public class MethodNode extends LineAttrNode implements ILoadable {
} }
initArguments(argsTypes); initArguments(argsTypes);
} catch (JadxRuntimeException e) { } catch (JadxRuntimeException e) {
LOG.error("Method signature parse error: " + this, e); LOG.error("Method signature parse error: {}", this, e);
return false; return false;
} }
return true; return true;
......
...@@ -41,7 +41,7 @@ final class LocalVar { ...@@ -41,7 +41,7 @@ final class LocalVar {
type = gType; type = gType;
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Can't parse signature for local variable: " + sign, e); LOG.error("Can't parse signature for local variable: {}", sign, e);
} }
} }
this.name = name; this.name = name;
......
...@@ -104,7 +104,7 @@ public class SimplifyVisitor extends AbstractVisitor { ...@@ -104,7 +104,7 @@ public class SimplifyVisitor extends AbstractVisitor {
&& ((LiteralArg) insn.getArg(1)).getLiteral() == 0) { && ((LiteralArg) insn.getArg(1)).getLiteral() == 0) {
insn.changeCondition(insn.getOp(), wi.getArg(0), wi.getArg(1)); insn.changeCondition(insn.getOp(), wi.getArg(0), wi.getArg(1));
} else { } else {
LOG.warn("TODO: cmp" + insn); LOG.warn("TODO: cmp {}", insn);
} }
} }
} }
......
...@@ -100,7 +100,7 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor { ...@@ -100,7 +100,7 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
TryCatchBlock prevTB = tryBlocksMap.put(domBlock, tb); TryCatchBlock prevTB = tryBlocksMap.put(domBlock, tb);
if (prevTB != null) { if (prevTB != null) {
LOG.info("!!! TODO: merge try blocks in " + mth); LOG.info("!!! TODO: merge try blocks in {}", mth);
} }
} }
} }
......
...@@ -70,7 +70,7 @@ public class RegionMaker { ...@@ -70,7 +70,7 @@ public class RegionMaker {
if (Consts.DEBUG) { if (Consts.DEBUG) {
int id = startBlock.getId(); int id = startBlock.getId();
if (processedBlocks.get(id)) { if (processedBlocks.get(id)) {
LOG.debug(" Block already processed: " + startBlock + ", mth: " + mth); LOG.debug(" Block already processed: {}, mth: {}", startBlock, mth);
} else { } else {
processedBlocks.set(id); processedBlocks.set(id);
} }
...@@ -502,9 +502,13 @@ public class RegionMaker { ...@@ -502,9 +502,13 @@ public class RegionMaker {
// invert simple condition (compiler often do it) // invert simple condition (compiler often do it)
currentIf = IfInfo.invert(currentIf); currentIf = IfInfo.invert(currentIf);
} }
currentIf = IfMakerHelper.restructureIf(mth, block, currentIf); IfInfo modifiedIf = IfMakerHelper.restructureIf(mth, block, currentIf);
if (currentIf == null) { if (modifiedIf != null) {
// invalid merged if, check simple one again currentIf = modifiedIf;
} else {
if (currentIf.getMergedBlocks().size() <= 1) {
return null;
}
currentIf = makeIfInfo(block); currentIf = makeIfInfo(block);
currentIf = IfMakerHelper.restructureIf(mth, block, currentIf); currentIf = IfMakerHelper.restructureIf(mth, block, currentIf);
if (currentIf == null) { if (currentIf == null) {
......
...@@ -73,7 +73,7 @@ public class ErrorsCounter { ...@@ -73,7 +73,7 @@ public class ErrorsCounter {
public void printReport() { public void printReport() {
if (getErrorCount() > 0) { if (getErrorCount() > 0) {
LOG.error(getErrorCount() + " errors occurred in following nodes:"); LOG.error("{} errors occurred in following nodes:", getErrorCount());
List<Object> nodes = new ArrayList<Object>(errorNodes); List<Object> nodes = new ArrayList<Object>(errorNodes);
Collections.sort(nodes, new Comparator<Object>() { Collections.sort(nodes, new Comparator<Object>() {
@Override @Override
...@@ -83,7 +83,7 @@ public class ErrorsCounter { ...@@ -83,7 +83,7 @@ public class ErrorsCounter {
}); });
for (Object node : nodes) { for (Object node : nodes) {
String nodeName = node.getClass().getSimpleName().replace("Node", ""); String nodeName = node.getClass().getSimpleName().replace("Node", "");
LOG.error(" " + nodeName + ": " + node); LOG.error(" {}: {}", nodeName, node);
} }
} }
} }
......
package jadx.core.utils; package jadx.core.utils;
import jadx.core.Consts;
import jadx.core.dex.attributes.AFlag; import jadx.core.dex.attributes.AFlag;
import jadx.core.dex.instructions.args.InsnArg; import jadx.core.dex.instructions.args.InsnArg;
import jadx.core.dex.instructions.args.InsnWrapArg; import jadx.core.dex.instructions.args.InsnWrapArg;
...@@ -66,9 +65,6 @@ public class InstructionRemover { ...@@ -66,9 +65,6 @@ public class InstructionRemover {
public static void unbindInsn(MethodNode mth, InsnNode insn) { public static void unbindInsn(MethodNode mth, InsnNode insn) {
RegisterArg r = insn.getResult(); RegisterArg r = insn.getResult();
if (r != null && r.getSVar() != null) { if (r != null && r.getSVar() != null) {
if (Consts.DEBUG && r.getSVar().getUseCount() != 0) {
LOG.debug("Unbind insn with result: {}", insn);
}
mth.removeSVar(r.getSVar()); mth.removeSVar(r.getSVar());
} }
for (InsnArg arg : insn.getArguments()) { for (InsnArg arg : insn.getArguments()) {
......
...@@ -66,7 +66,7 @@ public class InputFile { ...@@ -66,7 +66,7 @@ public class InputFile {
if (ba.length == 0) { if (ba.length == 0) {
throw new JadxException(j2d.isError() ? j2d.getDxErrors() : "Empty dx output"); throw new JadxException(j2d.isError() ? j2d.getDxErrors() : "Empty dx output");
} else if (j2d.isError()) { } else if (j2d.isError()) {
LOG.warn("dx message: " + j2d.getDxErrors()); LOG.warn("dx message: {}", j2d.getDxErrors());
} }
return new Dex(ba); return new Dex(ba);
} catch (Throwable e) { } catch (Throwable e) {
......
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