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 198ccd095..a6f64df99 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 @@ -870,19 +870,19 @@ protected void printAnnotationArrayValue(final Object value) { } protected void printFrameType(final Object type) { - if (type == Opcodes.TOP) { + if (Opcodes.TOP.equals(type)) { pw.print("Top"); - } else if (type == Opcodes.INTEGER) { + } else if (Opcodes.INTEGER.equals(type)) { pw.print("Integer"); - } else if (type == Opcodes.FLOAT) { + } else if (Opcodes.FLOAT.equals(type)) { pw.print("Float"); - } else if (type == Opcodes.LONG) { + } else if (Opcodes.LONG.equals(type)) { pw.print("Long"); - } else if (type == Opcodes.DOUBLE) { + } else if (Opcodes.DOUBLE.equals(type)) { pw.print("Double"); - } else if (type == Opcodes.NULL) { + } else if (Opcodes.NULL.equals(type)) { pw.print("Null"); - } else if (type == Opcodes.UNINITIALIZED_THIS) { + } else if (Opcodes.UNINITIALIZED_THIS.equals(type)) { pw.print("UninitializedThis"); } else if (type instanceof Label) { pw.print("Uninitialized "); 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 cce8e60e1..f61f5df82 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 @@ -17,8 +17,8 @@ public enum TypeClass { IF("i"), // JD("w"); // - public String name; - public boolean fixed; + public final String name; + public final boolean fixed; TypeClass(String use, boolean fixed) { this.name = use; diff --git a/dex-reader-api/src/main/java/com/googlecode/d2j/Visibility.java b/dex-reader-api/src/main/java/com/googlecode/d2j/Visibility.java index e49dc4c1e..5f1a73b34 100644 --- a/dex-reader-api/src/main/java/com/googlecode/d2j/Visibility.java +++ b/dex-reader-api/src/main/java/com/googlecode/d2j/Visibility.java @@ -7,7 +7,7 @@ public enum Visibility { BUILD(0), RUNTIME(1), SYSTEM(2); - public int value; + public final int value; // int VISIBILITY_BUILD = 0; // int VISIBILITY_RUNTIME = 1; diff --git a/dex-reader-api/src/main/java/com/googlecode/d2j/reader/InstructionFormat.java b/dex-reader-api/src/main/java/com/googlecode/d2j/reader/InstructionFormat.java index 27f7d7392..65bc71363 100644 --- a/dex-reader-api/src/main/java/com/googlecode/d2j/reader/InstructionFormat.java +++ b/dex-reader-api/src/main/java/com/googlecode/d2j/reader/InstructionFormat.java @@ -68,7 +68,7 @@ public enum InstructionFormat { // kFmt3rmi(3), // [opt] inline invoke/range - public int size; + public final int size; InstructionFormat(int size) { this.size = size; diff --git a/dex-reader-api/src/main/java/com/googlecode/d2j/reader/Op.java b/dex-reader-api/src/main/java/com/googlecode/d2j/reader/Op.java index 1908ba0b3..66629d8c9 100644 --- a/dex-reader-api/src/main/java/com/googlecode/d2j/reader/Op.java +++ b/dex-reader-api/src/main/java/com/googlecode/d2j/reader/Op.java @@ -291,19 +291,19 @@ public enum Op implements CFG { K_INSTR_CAN_CONTINUE | K_INSTR_CAN_THROW | K_INSTR_INVOKE, true), // BAD_OP(-1, "bad-opcode", null, kIndexNone, 0, false); // - public int opcode; + public final int opcode; - public InstructionFormat format; + public final InstructionFormat format; /* package */ InstructionIndexType indexType; /* package */ int flags; - public String displayName; + public final String displayName; public static final Op[] OPS = new Op[256]; - public boolean changeFrame; + public final boolean changeFrame; static { for (Op op : Op.values()) { @@ -340,6 +340,7 @@ public boolean canThrow() { this.format = fmt; this.indexType = indexType; this.flags = flags; + this.changeFrame = changeFrame; } public String toString() { diff --git a/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/ClassInfo.java b/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/ClassInfo.java index 1e7e4abec..543d88867 100644 --- a/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/ClassInfo.java +++ b/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/ClassInfo.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; public class ClassInfo { @@ -17,8 +18,16 @@ public ClassInfo(String name) { this.name = name; } + @Override public boolean equals(Object o) { - return name.equals(((ClassInfo) o).name); + if (this == o) { + return true; + } + if (!(o instanceof ClassInfo)) { + return false; + } + ClassInfo classInfo = (ClassInfo) o; + return Objects.equals(name, classInfo.name); } public int hashCode() { diff --git a/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InitOut.java b/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InitOut.java index b1b3d3f9f..7c1326baf 100644 --- a/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InitOut.java +++ b/dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InitOut.java @@ -3,6 +3,7 @@ import com.googlecode.dex2jar.tools.BaseCmd; import com.googlecode.dex2jar.tools.Constants; import java.io.IOException; +import java.io.Serializable; import java.nio.charset.StandardCharsets; import java.nio.file.FileSystem; import java.nio.file.Files; @@ -448,7 +449,7 @@ private static class MemberInfo { } - private static class MemberInfoComparator implements Comparator { + private static class MemberInfoComparator implements Comparator, Serializable { @Override public int compare(MemberInfo memberInfo, MemberInfo memberInfo2) { 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 c5583b951..dc4fcc67b 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 @@ -27,7 +27,7 @@ protected void doCommandLine() throws Exception { return; } - System.err.printf("fix %s -> %s\n", remainingArgs[0], output); + System.err.printf("fix %s -> %s%n", remainingArgs[0], output); byte[] buffer = new byte[1000]; try (ZipOutputStream zos = new AutoSTOREDZipOutputStream(Files.newOutputStream(output))) { diff --git a/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/item/SectionItem.java b/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/item/SectionItem.java index 0e9969431..109b60574 100644 --- a/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/item/SectionItem.java +++ b/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/item/SectionItem.java @@ -32,7 +32,7 @@ public static void main(String... strings) throws IllegalArgumentException, Ille for (Field f : SectionItem.class.getFields()) { if (f.getType().equals(int.class)) { if (0 != (f.getModifiers() & Modifier.STATIC)) { - System.out.printf("%s(0x%04x,0,0),//\n", f.getName(), f.get(null)); + System.out.printf("%s(0x%04x,0,0),//%n", f.getName(), f.get(null)); } } } @@ -109,9 +109,9 @@ public enum SectionType { TYPE_ENCODED_ARRAY_ITEM(0x2005, 1, 0), // TYPE_ANNOTATIONS_DIRECTORY_ITEM(0x2006, 4, 0); // - public int code; + public final int code; - public int alignment; + public final int alignment; SectionType(int typeCode, int alignment, int size) { this.code = typeCode;