diff --git a/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jar2JasminCmd.java b/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jar2JasminCmd.java index bce07a08..b5f2fd7c 100644 --- a/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jar2JasminCmd.java +++ b/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jar2JasminCmd.java @@ -16,21 +16,17 @@ */ package com.googlecode.d2j.jasmin; -import java.io.*; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.Charset; -import java.nio.file.*; -import java.nio.file.FileSystem; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.HashMap; -import java.util.Map; - import com.googlecode.dex2jar.tools.BaseCmd; +import com.googlecode.dex2jar.tools.BaseCmd.Syntax; import org.objectweb.asm.ClassReader; import org.objectweb.asm.tree.ClassNode; -import com.googlecode.dex2jar.tools.BaseCmd.Syntax; +import java.io.*; +import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.nio.file.FileSystem; +import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; @Syntax(cmd = "d2j-jar2jasmin", syntax = "[options] ", desc = "Disassemble .class in jar file to jasmin file", onlineHelp = "https://code.google.com/p/dex2jar/wiki/Jasmin") public class Jar2JasminCmd extends BaseCmd { @@ -43,7 +39,7 @@ public class Jar2JasminCmd extends BaseCmd { @Opt(opt = "e", longOpt = "encoding", description = "encoding for .j files, default is UTF-8", argName = "enc") private String encoding = "UTF-8"; - public static void main(String[] args) { + public static void main(String... args) { new Jar2JasminCmd().doMain(args); } diff --git a/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmin2JarCmd.java b/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmin2JarCmd.java index dfa7cfc9..c5c76661 100644 --- a/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmin2JarCmd.java +++ b/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmin2JarCmd.java @@ -16,18 +16,7 @@ */ package com.googlecode.d2j.jasmin; -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.charset.Charset; -import java.nio.file.*; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.HashMap; -import java.util.Map; - +import com.googlecode.dex2jar.tools.BaseCmd; import org.antlr.runtime.ANTLRReaderStream; import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.CommonTokenStream; @@ -36,7 +25,14 @@ import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.ClassNode; -import com.googlecode.dex2jar.tools.BaseCmd; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.nio.file.*; +import java.nio.file.attribute.BasicFileAttributes; @BaseCmd.Syntax(cmd = "d2j-jasmin2jar", syntax = "[options] ", desc = "Assemble .j files to .class file", onlineHelp = "https://code.google.com/p/dex2jar/wiki/Jasmin") public class Jasmin2JarCmd extends BaseCmd implements Opcodes { @@ -58,7 +54,7 @@ public class Jasmin2JarCmd extends BaseCmd implements Opcodes { @Opt(opt = "cv", longOpt = "class-version", description = "default .class version, [1~9], default 6 for JAVA6") private int classVersion = 6; - public static void main(String[] args) throws ClassNotFoundException, SecurityException { + public static void main(String... args) throws ClassNotFoundException, SecurityException { new Jasmin2JarCmd().doMain(args); } diff --git a/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/JasminDumper.java b/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/JasminDumper.java index 8fb74b91..b2cf3f92 100644 --- a/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/JasminDumper.java +++ b/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/JasminDumper.java @@ -442,7 +442,7 @@ public class JasminDumper implements Opcodes { } @Override - public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) { + public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) { pw.print("tableswitch "); pw.println(min); for (Label label : labels) { diff --git a/d2j-smali/src/main/java/com/googlecode/d2j/smali/BaksmaliDexFileVisitor.java b/d2j-smali/src/main/java/com/googlecode/d2j/smali/BaksmaliDexFileVisitor.java index 32e69c5b..486d60f1 100644 --- a/d2j-smali/src/main/java/com/googlecode/d2j/smali/BaksmaliDexFileVisitor.java +++ b/d2j-smali/src/main/java/com/googlecode/d2j/smali/BaksmaliDexFileVisitor.java @@ -5,7 +5,6 @@ import com.googlecode.d2j.visitors.DexClassVisitor; import com.googlecode.d2j.visitors.DexFileVisitor; import java.io.BufferedWriter; -import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; diff --git a/d2j-smali/src/test/java/a/SmaliTest.java b/d2j-smali/src/test/java/a/SmaliTest.java index ed798a8b..2ed7b66a 100644 --- a/d2j-smali/src/test/java/a/SmaliTest.java +++ b/d2j-smali/src/test/java/a/SmaliTest.java @@ -1,6 +1,5 @@ package a; -import com.googlecode.d2j.dex.writer.DexFileWriter; import com.googlecode.d2j.node.DexClassNode; import com.googlecode.d2j.node.DexFileNode; import com.googlecode.d2j.smali.BaksmaliDumpOut; diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/IrMethod.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/IrMethod.java index 4cd36d02..74777b9e 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/IrMethod.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/IrMethod.java @@ -20,7 +20,6 @@ import java.util.List; import com.googlecode.dex2jar.ir.expr.Local; import com.googlecode.dex2jar.ir.stmt.LabelStmt; -import com.googlecode.dex2jar.ir.stmt.Stmt; import com.googlecode.dex2jar.ir.stmt.StmtList; /** diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/LocalVar.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/LocalVar.java index 18ebd314..fca04674 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/LocalVar.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/LocalVar.java @@ -1,7 +1,5 @@ package com.googlecode.dex2jar.ir; -import java.util.Map; - import com.googlecode.dex2jar.ir.expr.Local; import com.googlecode.dex2jar.ir.stmt.LabelStmt; diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/Trap.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/Trap.java index d43453b5..5ba1b95b 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/Trap.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/Trap.java @@ -15,8 +15,6 @@ */ package com.googlecode.dex2jar.ir; -import java.util.Map; - import com.googlecode.dex2jar.ir.stmt.LabelStmt; /** diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/TypeClass.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/TypeClass.java index 6c27b0d2..5e7f5444 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/TypeClass.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/TypeClass.java @@ -118,6 +118,7 @@ public enum TypeClass { case JD: throw new RuntimeException(); + default: } case ZIFL: switch (clz) { @@ -129,6 +130,7 @@ public enum TypeClass { case JD: throw new RuntimeException(); + default: } case IF: switch (clz) { @@ -141,6 +143,7 @@ public enum TypeClass { case JD: throw new RuntimeException(); + default: } case ZIF: switch (clz) { @@ -154,6 +157,7 @@ public enum TypeClass { case JD: throw new RuntimeException(); + default: } case ZI: switch (clz) { @@ -165,9 +169,11 @@ public enum TypeClass { return thizCls; case JD: throw new RuntimeException(); + default: } case JD: throw new RuntimeException(); + default: } } } diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/AggTransformer.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/AggTransformer.java index e397e466..aadc2353 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/AggTransformer.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/AggTransformer.java @@ -42,6 +42,7 @@ public class AggTransformer extends StatedTransformer { case NOP: case RETURN_VOID: continue; + default: } try { localCanExecFirst(local, next); @@ -100,6 +101,7 @@ public class AggTransformer extends StatedTransformer { localCanExecFirst(local, op1.getOp2()); localCanExecFirst(local, op2); break; + default: } break; } @@ -300,6 +302,7 @@ public class AggTransformer extends StatedTransformer { case FCMPL: case NOT: return true; + default: } return false; } diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/EndRemover.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/EndRemover.java index e8bc06b1..7c8a3709 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/EndRemover.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/EndRemover.java @@ -1,22 +1,13 @@ package com.googlecode.dex2jar.ir.ts; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - import com.googlecode.dex2jar.ir.IrMethod; import com.googlecode.dex2jar.ir.LabelAndLocalMapper; import com.googlecode.dex2jar.ir.Trap; import com.googlecode.dex2jar.ir.expr.Local; -import com.googlecode.dex2jar.ir.expr.Value.VT; -import com.googlecode.dex2jar.ir.stmt.GotoStmt; -import com.googlecode.dex2jar.ir.stmt.IfStmt; -import com.googlecode.dex2jar.ir.stmt.LabelStmt; -import com.googlecode.dex2jar.ir.stmt.Stmt; -import com.googlecode.dex2jar.ir.stmt.Stmt.E2Stmt; +import com.googlecode.dex2jar.ir.stmt.*; import com.googlecode.dex2jar.ir.stmt.Stmt.ST; -import com.googlecode.dex2jar.ir.stmt.StmtList; -import com.googlecode.dex2jar.ir.stmt.Stmts; + +import java.util.ArrayList; /** * Try to clean following between a {@link Trap} diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/ExceptionHandlerCurrectTransformer.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/ExceptionHandlerCurrectTransformer.java index 5d38fe4d..7d328307 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/ExceptionHandlerCurrectTransformer.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/ExceptionHandlerCurrectTransformer.java @@ -20,7 +20,6 @@ import com.googlecode.dex2jar.ir.Trap; import com.googlecode.dex2jar.ir.expr.Exprs; import com.googlecode.dex2jar.ir.expr.Local; import com.googlecode.dex2jar.ir.expr.Value.VT; -import com.googlecode.dex2jar.ir.stmt.AssignStmt; import com.googlecode.dex2jar.ir.stmt.GotoStmt; import com.googlecode.dex2jar.ir.stmt.LabelStmt; import com.googlecode.dex2jar.ir.stmt.Stmt; diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/ExceptionHandlerTrim.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/ExceptionHandlerTrim.java index 5f5c074c..9a0f1e07 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/ExceptionHandlerTrim.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/ExceptionHandlerTrim.java @@ -16,11 +16,6 @@ */ package com.googlecode.dex2jar.ir.ts; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import com.googlecode.dex2jar.ir.IrMethod; import com.googlecode.dex2jar.ir.LabelAndLocalMapper; import com.googlecode.dex2jar.ir.Trap; @@ -29,6 +24,9 @@ import com.googlecode.dex2jar.ir.stmt.Stmt; import com.googlecode.dex2jar.ir.stmt.Stmt.ST; import com.googlecode.dex2jar.ir.stmt.Stmts; +import java.util.ArrayList; +import java.util.List; + /** * Trim Exception handler. * @@ -74,7 +72,7 @@ import com.googlecode.dex2jar.ir.stmt.Stmts; */ public class ExceptionHandlerTrim implements Transformer { - @SuppressWarnings({ "serial", "unchecked", "rawtypes" }) + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void transform(IrMethod irMethod) { List trips = irMethod.traps; diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/JimpleTransformer.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/JimpleTransformer.java index f4eb1b48..b32d3c0a 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/JimpleTransformer.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/JimpleTransformer.java @@ -90,6 +90,7 @@ public class JimpleTransformer implements Transformer { case NEW: case STATIC_FIELD: return tmp.newAssign(x); + default: } } break; diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/NpeTransformer.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/NpeTransformer.java index def7919c..ab06e69a 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/NpeTransformer.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/NpeTransformer.java @@ -16,9 +16,6 @@ */ package com.googlecode.dex2jar.ir.ts; -import java.util.HashSet; -import java.util.Set; - import com.googlecode.dex2jar.ir.IrMethod; import com.googlecode.dex2jar.ir.StmtTraveler; import com.googlecode.dex2jar.ir.expr.Constant; @@ -44,7 +41,6 @@ public class NpeTransformer extends StatedTransformer { if (method.locals.size() == 0) { return false; } - Set npes = new HashSet<>(); StmtTraveler st = new StmtTraveler() { @Override public Stmt travel(Stmt stmt) { @@ -79,7 +75,7 @@ public class NpeTransformer extends StatedTransformer { } } break; - + default: } return op; } @@ -131,7 +127,7 @@ public class NpeTransformer extends StatedTransformer { } } break; - + default: } Value sop = super.travel(op); if (sop.vt == Value.VT.LOCAL || sop.vt == Value.VT.CONSTANT) { @@ -179,6 +175,7 @@ public class NpeTransformer extends StatedTransformer { } } break; + case En: } } catch (XNPE e) { m.stmts.insertBefore(p, diff --git a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/TypeTransformer.java b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/TypeTransformer.java index ff2865c6..2e48b4bf 100644 --- a/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/TypeTransformer.java +++ b/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/TypeTransformer.java @@ -164,6 +164,7 @@ public class TypeTransformer implements Transformer { case INT: case IF: return "I"; + default: } throw new RuntimeException(); } @@ -278,6 +279,8 @@ public class TypeTransformer implements Transformer { case DOUBLE: case VOID: ref.provideDesc = clz.name; + break; + default: } String provideDesc = ref.provideDesc; if (provideDesc == null && ref.parents != null && ref.parents.size() > 1) { @@ -469,6 +472,7 @@ public class TypeTransformer implements Transformer { provideAs(cst, "L"); } break; + default: } } @@ -528,6 +532,7 @@ public class TypeTransformer implements Transformer { useAs(v, ue.type); } break; + default: } if (v != null) { exExpr(v); @@ -686,6 +691,7 @@ public class TypeTransformer implements Transformer { linkFromTo(vb, enExpr); } break; + default: } for (Value vb : enExpr.ops) { exExpr(vb); @@ -798,6 +804,7 @@ public class TypeTransformer implements Transformer { case RETURN: useAs(op, method.ret); break; + default: } exExpr(op); } diff --git a/dex-ir/src/test/java/com/googlecode/dex2jar/ir/test/RemoveLocalFromSSATest.java b/dex-ir/src/test/java/com/googlecode/dex2jar/ir/test/RemoveLocalFromSSATest.java index a156f664..eaccd2c5 100644 --- a/dex-ir/src/test/java/com/googlecode/dex2jar/ir/test/RemoveLocalFromSSATest.java +++ b/dex-ir/src/test/java/com/googlecode/dex2jar/ir/test/RemoveLocalFromSSATest.java @@ -1,18 +1,14 @@ package com.googlecode.dex2jar.ir.test; -import static com.googlecode.dex2jar.ir.expr.Exprs.*; -import static com.googlecode.dex2jar.ir.stmt.Stmts.*; - -import com.googlecode.dex2jar.ir.expr.Value; +import com.googlecode.dex2jar.ir.expr.Local; +import com.googlecode.dex2jar.ir.stmt.Stmt; import com.googlecode.dex2jar.ir.ts.RemoveLocalFromSSA; import org.junit.Assert; import org.junit.Test; -import com.googlecode.dex2jar.ir.expr.Exprs; -import com.googlecode.dex2jar.ir.expr.Local; -import com.googlecode.dex2jar.ir.stmt.LabelStmt; -import com.googlecode.dex2jar.ir.stmt.Stmt; -import com.googlecode.dex2jar.ir.ts.RemoveConstantFromSSA; +import static com.googlecode.dex2jar.ir.expr.Exprs.nInt; +import static com.googlecode.dex2jar.ir.stmt.Stmts.nAssign; +import static com.googlecode.dex2jar.ir.stmt.Stmts.nReturn; public class RemoveLocalFromSSATest extends BaseTransformerTest { @Test diff --git a/dex-tools/src/main/java/com/googlecode/d2j/map/AutoDetectSourceProcess.java b/dex-tools/src/main/java/com/googlecode/d2j/map/AutoDetectSourceProcess.java index 27c6ba4b..1c9dce08 100644 --- a/dex-tools/src/main/java/com/googlecode/d2j/map/AutoDetectSourceProcess.java +++ b/dex-tools/src/main/java/com/googlecode/d2j/map/AutoDetectSourceProcess.java @@ -27,7 +27,6 @@ public class AutoDetectSourceProcess { public final void process(String file) throws IOException { Path path = new File(file).toPath(); - final int basePathLength = path.getNameCount(); if (Files.isDirectory(path)) { Files.walkFileTree(path, new SimpleFileVisitor() { diff --git a/dex-tools/src/main/java/com/googlecode/d2j/map/ProguardMappingParser.java b/dex-tools/src/main/java/com/googlecode/d2j/map/ProguardMappingParser.java index d952be71..26f41f80 100644 --- a/dex-tools/src/main/java/com/googlecode/d2j/map/ProguardMappingParser.java +++ b/dex-tools/src/main/java/com/googlecode/d2j/map/ProguardMappingParser.java @@ -75,7 +75,6 @@ public class ProguardMappingParser { String fieldNameOrMethodNameDesc = as[1]; String newName = as[3]; - String key; if (fieldNameOrMethodNameDesc.contains("(")) { // a method int idx = fieldNameOrMethodNameDesc.indexOf('('); diff --git a/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InvocationWeaver.java b/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InvocationWeaver.java index b66238e9..50ec8c4d 100644 --- a/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InvocationWeaver.java +++ b/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InvocationWeaver.java @@ -1,6 +1,5 @@ package com.googlecode.d2j.tools.jar; -import com.googlecode.d2j.reader.zip.ZipUtil; import com.googlecode.dex2jar.tools.BaseCmd; import org.objectweb.asm.*; import org.objectweb.asm.commons.Remapper; @@ -92,7 +91,7 @@ public class InvocationWeaver implements Opcodes { private static final String DEFAULT_RET_TYPE = "Ld/$$$/j;"; private static final String DEFAULT_DESC = "(L;)" + DEFAULT_RET_TYPE; private static final Type OBJECT_TYPE = Type.getType(Object.class); - private static String BASE_INVOCATION_TYPE_FMT = "d2j/gen/MI_%03d"; + private static final String BASE_INVOCATION_TYPE_FMT = "d2j/gen/MI_%03d"; List callbacks = new ArrayList(); int currentInvocationIdx = 0; private MtdInfo key = new MtdInfo(); @@ -272,13 +271,12 @@ public class InvocationWeaver implements Opcodes { n.owner = t.owner; n.name = t.name + "$$$_A_"; - int acc = 0; String nDesc = t.desc; boolean hasThis = opcode != INVOKESTATIC; Type[] args = Type.getArgumentTypes(t.desc); Type ret = Type.getReturnType(t.desc); if (hasThis) { - List ts = new ArrayList(5); + List ts = new ArrayList<>(5); ts.add(Type.getObjectType(t.owner)); ts.addAll(Arrays.asList(args)); nDesc = Type.getMethodDescriptor(ret, ts.toArray(new Type[ts.size()])); diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/ApkSign.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/ApkSign.java index 873a52c0..a6c9f02f 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/ApkSign.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/ApkSign.java @@ -34,7 +34,7 @@ import com.googlecode.d2j.signapk.TinySignImpl; @BaseCmd.Syntax(cmd = "d2j-apk-sign", syntax = "[options] ", desc = "Sign an android apk file use a test certificate.") public class ApkSign extends BaseCmd { - public static void main(String[] args) { + public static void main(String... args) { new ApkSign().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/AsmVerify.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/AsmVerify.java index e7d87e85..036d2e32 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/AsmVerify.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/AsmVerify.java @@ -48,7 +48,7 @@ public class AsmVerify extends BaseCmd { return n == -1 ? name : "o"; } - public static void main(String[] args) { + public static void main(String... args) { new AsmVerify().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DeObfInitCmd.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DeObfInitCmd.java index fa1ad64c..c9d1433f 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DeObfInitCmd.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DeObfInitCmd.java @@ -34,7 +34,7 @@ public class DeObfInitCmd extends BaseCmd { super("d2j-init-deobf [options] ", "generate an init config file for deObfuscate a jar"); } - public static void main(String[] args) { + public static void main(String... args) { new DeObfInitCmd().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DecryptStringCmd.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DecryptStringCmd.java index 9a3494c2..447f7eb6 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DecryptStringCmd.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DecryptStringCmd.java @@ -37,7 +37,7 @@ import com.googlecode.dex2jar.tools.BaseCmd.Syntax; @Syntax(cmd = "d2j-decrypt-string", syntax = "[options] ", desc = "Decrypt in class file", onlineHelp = "https://code.google.com/p/dex2jar/wiki/DecryptStrings") public class DecryptStringCmd extends BaseCmd { - public static void main(String[] args) { + public static void main(String... args) { new DecryptStringCmd().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Dex2jarCmd.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Dex2jarCmd.java index 88b8352b..eaa579ac 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Dex2jarCmd.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Dex2jarCmd.java @@ -28,7 +28,7 @@ import com.googlecode.dex2jar.ir.ET; @BaseCmd.Syntax(cmd = "d2j-dex2jar", syntax = "[options] [file1 ... fileN]", desc = "convert dex to jar") public class Dex2jarCmd extends BaseCmd { - public static void main(String[] args) { + public static void main(String... args) { new Dex2jarCmd().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DexRecomputeChecksum.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DexRecomputeChecksum.java index 7f02a2cf..aa8b7005 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DexRecomputeChecksum.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DexRecomputeChecksum.java @@ -19,20 +19,14 @@ package com.googlecode.dex2jar.tools; import com.googlecode.d2j.dex.writer.DexFileWriter; import java.io.File; -import java.io.IOException; -import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; @BaseCmd.Syntax(cmd = "d2j-dex-recompute-checksum", syntax = "[options] dex", desc = "recompute crc and sha1 of dex.") public class DexRecomputeChecksum extends BaseCmd { - public static void main(String[] args) { + public static void main(String... args) { new DexRecomputeChecksum().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DexWeaverCmd.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DexWeaverCmd.java index 51915f32..dbb4703a 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DexWeaverCmd.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/DexWeaverCmd.java @@ -89,6 +89,8 @@ public class DexWeaverCmd extends BaseCmd { case INVOKE_VIRTUAL_RANGE: super.visitMethodStmt(Op.INVOKE_STATIC_RANGE, args, replaceTo); break; + default: + // impossible here } } else { super.visitMethodStmt(op, args, method); diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/GenerateCompileStubFromOdex.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/GenerateCompileStubFromOdex.java index 8577c8b8..ae4f67ef 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/GenerateCompileStubFromOdex.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/GenerateCompileStubFromOdex.java @@ -19,7 +19,7 @@ public class GenerateCompileStubFromOdex extends BaseCmd { private static final int MAGIC_ODEX = 0x0A796564 & 0x00FFFFFF;// hex for 'dey ', ignore the 0A private static final int MAGIC_DEX = 0x0A786564 & 0x00FFFFFF;// hex for 'dex ', ignore the 0A - public static void main(String[] args) { + public static void main(String... args) { new GenerateCompileStubFromOdex().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Jar2Dex.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Jar2Dex.java index 640f3763..08dacdb1 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Jar2Dex.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Jar2Dex.java @@ -28,7 +28,7 @@ import java.util.List; @BaseCmd.Syntax(cmd = "d2j-jar2dex", syntax = "[options] ", desc = "Convert jar to dex by invoking dx.") public class Jar2Dex extends BaseCmd { - public static void main(String[] args) { + public static void main(String... args) { new Jar2Dex().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/JarAccessCmd.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/JarAccessCmd.java index f6be32b4..1bbf3842 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/JarAccessCmd.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/JarAccessCmd.java @@ -26,7 +26,7 @@ import org.objectweb.asm.*; @BaseCmd.Syntax(cmd = "d2j-jar-access", syntax = "[options] ", desc = "add or remove class/method/field access in jar file") public class JarAccessCmd extends BaseCmd implements Opcodes { - public static void main(String[] args) { + public static void main(String... args) { new JarAccessCmd().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/JarRemap.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/JarRemap.java index b3993b48..e2a19db0 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/JarRemap.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/JarRemap.java @@ -23,7 +23,7 @@ import com.googlecode.dex2jar.tools.BaseCmd.Syntax; @Syntax(cmd = "d2j-jar-remap", syntax = "[options] jar", desc = "rename package/class/method/field name in a jar", onlineHelp = "https://code.google.com/p/dex2jar/wiki/DeObfuscateJarWithDexTool") public class JarRemap extends BaseCmd { - public static void main(String[] args) { + public static void main(String... args) { new JarRemap().doMain(args); } diff --git a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/StdApkCmd.java b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/StdApkCmd.java index bafb9b46..e3c15cc2 100644 --- a/dex-tools/src/main/java/com/googlecode/dex2jar/tools/StdApkCmd.java +++ b/dex-tools/src/main/java/com/googlecode/dex2jar/tools/StdApkCmd.java @@ -32,7 +32,7 @@ public class StdApkCmd extends BaseCmd { @Opt(opt = "o", longOpt = "output", description = "The output file", argName = "out", required = true) private Path output; - public static void main(String[] args) { + public static void main(String... args) { new StdApkCmd().doMain(args); } @@ -48,26 +48,27 @@ public class StdApkCmd extends BaseCmd { byte[] buffer = new byte[1000]; try (ZipOutputStream zos = new AutoSTOREDZipOutputStream(Files.newOutputStream(output))) { byte[] data = Files.readAllBytes(new File(remainingArgs[0]).toPath()); - com.googlecode.d2j.util.zip.ZipFile zipFile = new com.googlecode.d2j.util.zip.ZipFile(data); - for (com.googlecode.d2j.util.zip.ZipEntry e : zipFile.entries()) { - ZipEntry nEntry = new ZipEntry(e.getName()); + try(com.googlecode.d2j.util.zip.ZipFile zipFile = new com.googlecode.d2j.util.zip.ZipFile(data)) { + for (com.googlecode.d2j.util.zip.ZipEntry e : zipFile.entries()) { + ZipEntry nEntry = new ZipEntry(e.getName()); - nEntry.setMethod(e.getMethod() == com.googlecode.d2j.util.zip.ZipEntry.STORED ? ZipEntry.STORED - : ZipEntry.DEFLATED); - zos.putNextEntry(nEntry); + nEntry.setMethod(e.getMethod() == com.googlecode.d2j.util.zip.ZipEntry.STORED ? ZipEntry.STORED + : ZipEntry.DEFLATED); + zos.putNextEntry(nEntry); - if (!nEntry.isDirectory()) { - try (InputStream is = zipFile.getInputStream(e)) { - while (true) { - int c = is.read(buffer); - if (c < 0) { - break; + if (!nEntry.isDirectory()) { + try (InputStream is = zipFile.getInputStream(e)) { + while (true) { + int c = is.read(buffer); + if (c < 0) { + break; + } + zos.write(buffer, 0, c); } - zos.write(buffer, 0, c); } } + zos.closeEntry(); } - zos.closeEntry(); } zos.finish(); } diff --git a/dex-tools/src/test/java/com/googlecode/d2j/tools/jar/test/WaveTest.java b/dex-tools/src/test/java/com/googlecode/d2j/tools/jar/test/WaveTest.java index 5d9cb954..82261bab 100644 --- a/dex-tools/src/test/java/com/googlecode/d2j/tools/jar/test/WaveTest.java +++ b/dex-tools/src/test/java/com/googlecode/d2j/tools/jar/test/WaveTest.java @@ -61,21 +61,21 @@ public class WaveTest { FileSystem fs = BaseCmd.openZip(new File(WaveTest.class.getResource("/wave.jar").getPath()).toPath())) { w.wave(fs.getPath("/"), fs2.getPath("/")); } - URLClassLoader cl = new URLClassLoader(new URL[] { tmp.toURI().toURL() }, WaveTest.class.getClassLoader()); - Class clz = cl.loadClass("com.googlecode.d2j.tools.jar.test.res.Res"); - List list = (List) clz.newInstance(); - Assert.assertFalse(list.add("")); - Assert.assertEquals(-1, list.size()); + try(URLClassLoader cl = new URLClassLoader(new URL[] { tmp.toURI().toURL() }, WaveTest.class.getClassLoader())) { + Class clz = cl.loadClass("com.googlecode.d2j.tools.jar.test.res.Res"); + List list = (List) clz.newInstance(); + Assert.assertFalse(list.add("")); + Assert.assertEquals(-1, list.size()); - Method m = clz.getMethod("main", String[].class); - System.out.println(m); - m.invoke(null, new Object[] { null }); - Assert.assertTrue(appendCalled); - Assert.assertTrue(printlnCalled); + Method m = clz.getMethod("main", String[].class); + System.out.println(m); + m.invoke(null, new Object[]{null}); + Assert.assertTrue(appendCalled); + Assert.assertTrue(printlnCalled); - list = null; - cl.close(); - tmp.delete(); + list = null; + tmp.delete(); + } } } diff --git a/dex-translator/src/main/java/com/googlecode/d2j/dex/BaseDexExceptionHandler.java b/dex-translator/src/main/java/com/googlecode/d2j/dex/BaseDexExceptionHandler.java index 3da8052a..ee697e42 100644 --- a/dex-translator/src/main/java/com/googlecode/d2j/dex/BaseDexExceptionHandler.java +++ b/dex-translator/src/main/java/com/googlecode/d2j/dex/BaseDexExceptionHandler.java @@ -16,18 +16,13 @@ */ package com.googlecode.d2j.dex; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.HashMap; -import java.util.Map; - +import com.googlecode.d2j.Method; +import com.googlecode.d2j.node.DexMethodNode; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; -import com.googlecode.d2j.Method; -import com.googlecode.d2j.node.DexMethodNode; -import com.googlecode.d2j.reader.DexFileReader; -import com.googlecode.dex2jar.ir.ET; +import java.io.PrintWriter; +import java.io.StringWriter; public class BaseDexExceptionHandler implements DexExceptionHandler { @Override diff --git a/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2IrAdapter.java b/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2IrAdapter.java index b6c3d4e3..42b096ff 100644 --- a/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2IrAdapter.java +++ b/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2IrAdapter.java @@ -78,7 +78,6 @@ import com.googlecode.dex2jar.ir.stmt.LabelStmt; import com.googlecode.dex2jar.ir.stmt.Stmt; import com.googlecode.dex2jar.ir.stmt.StmtList; import com.googlecode.dex2jar.ir.stmt.Stmts; -import org.objectweb.asm.tree.LabelNode; /** * @author Panxiaobo diff --git a/dex-translator/src/main/java/com/googlecode/d2j/dex/DexExceptionHandler.java b/dex-translator/src/main/java/com/googlecode/d2j/dex/DexExceptionHandler.java index 7ada81c7..10dcf6a1 100644 --- a/dex-translator/src/main/java/com/googlecode/d2j/dex/DexExceptionHandler.java +++ b/dex-translator/src/main/java/com/googlecode/d2j/dex/DexExceptionHandler.java @@ -16,12 +16,9 @@ */ package com.googlecode.d2j.dex; +import com.googlecode.d2j.Method; import com.googlecode.d2j.node.DexMethodNode; import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.tree.MethodNode; - -import com.googlecode.d2j.Method; -import com.googlecode.dex2jar.ir.IrMethod; public interface DexExceptionHandler { public void handleFileException(Exception e); diff --git a/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/insn/JumpOp.java b/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/insn/JumpOp.java index 6d7d328d..976613df 100644 --- a/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/insn/JumpOp.java +++ b/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/insn/JumpOp.java @@ -21,6 +21,7 @@ public class JumpOp extends OpInsn { CodeWriter.checkRegA(op, "vA", a); CodeWriter.checkRegA(op, "vB", b); break; + default: } this.label = label; this.a = a; @@ -54,6 +55,8 @@ public class JumpOp extends OpInsn { CodeWriter.checkContentShort(op, "+BBBB", offset); out.put((byte) a).putShort((short) offset); break; + default: + throw new RuntimeException("not support"); } } } \ No newline at end of file