Commit 73dd55ea authored by Skylot's avatar Skylot

core: fix code style issues

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