提交 84cb6b95 编写于 作者: S Skylot

Merge branch 'master' into type-inference-wip

# Conflicts:
#	jadx-core/src/main/java/jadx/core/codegen/NameGen.java
#	jadx-core/src/main/java/jadx/core/dex/attributes/AttributeStorage.java
#	jadx-core/src/main/java/jadx/core/dex/attributes/nodes/PhiListAttr.java
#	jadx-core/src/main/java/jadx/core/dex/instructions/IndexInsnNode.java
#	jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java
#	jadx-core/src/main/java/jadx/core/dex/instructions/args/ArgType.java
#	jadx-core/src/main/java/jadx/core/dex/instructions/args/RegisterArg.java
#	jadx-core/src/main/java/jadx/core/dex/instructions/args/SSAVar.java
#	jadx-core/src/main/java/jadx/core/dex/regions/conditions/IfRegion.java
#	jadx-core/src/main/java/jadx/core/dex/visitors/ModVisitor.java
#	jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/helpers/BlocksPair.java
#	jadx-core/src/main/java/jadx/core/dex/visitors/blocksmaker/helpers/BlocksRemoveInfo.java
#	jadx-core/src/main/java/jadx/core/dex/visitors/debuginfo/LocalVar.java
#	jadx-core/src/main/java/jadx/core/dex/visitors/regions/ProcessVariables.java
#	jadx-core/src/main/java/jadx/core/dex/visitors/shrink/CodeShrinkVisitor.java
#	jadx-core/src/main/java/jadx/core/xmlgen/entry/EntryConfig.java
......@@ -90,7 +90,7 @@ public class JCommanderWrapper<T> {
if (fieldType == int.class) {
try {
int val = f.getInt(args);
opt.append(" (default: ").append(val).append(")");
opt.append(" (default: ").append(val).append(')');
} catch (Exception e) {
// ignore
}
......
......@@ -57,6 +57,6 @@ public final class CodePosition {
@Override
public String toString() {
return line + ":" + offset + (node != null ? " " + node : "");
return line + ':' + offset + (node != null ? " " + node : "");
}
}
......@@ -499,12 +499,12 @@ public class InsnGen {
case PHI:
fallbackOnlyInsn(insn);
code.add(insn.getType().toString()).add("(");
code.add(insn.getType().toString()).add('(');
for (InsnArg insnArg : insn.getArguments()) {
addArg(code, insnArg);
code.add(' ');
}
code.add(")");
code.add(')');
break;
default:
......
......@@ -184,9 +184,9 @@ public class MethodGen {
code.startLine("throw new UnsupportedOperationException(\"Method not decompiled: ")
.add(clsAlias.makeFullClsName(clsAlias.getShortName(), true))
.add(".")
.add('.')
.add(mth.getAlias())
.add("(")
.add('(')
.add(Utils.listToString(mth.getMethodInfo().getArgumentsTypes()))
.add("):")
.add(mth.getMethodInfo().getReturnType().toString())
......
......@@ -129,7 +129,7 @@ public class TypeGen {
}
String str = Long.toString(l);
if (Math.abs(l) >= Integer.MAX_VALUE) {
str += "L";
str += 'L';
}
return str;
}
......
......@@ -169,7 +169,7 @@ public class SignatureParser {
// generic type start ('<')
String obj = slice();
if (!incompleteType) {
obj += ";";
obj += ';';
}
ArgType[] genArr = consumeGenericArgs();
consume('>');
......@@ -211,7 +211,7 @@ public class SignatureParser {
list.add(type);
}
} while (type != null && !lookAhead('>'));
return list.toArray(new ArgType[list.size()]);
return list.toArray(new ArgType[0]);
}
/**
......
......@@ -67,7 +67,7 @@ public class FileUtils {
public static File createTempFile(String suffix) {
File temp;
try {
temp = File.createTempFile("jadx-tmp-", System.nanoTime() + "-" + suffix);
temp = File.createTempFile("jadx-tmp-", System.nanoTime() + '-' + suffix);
temp.deleteOnExit();
} catch (IOException e) {
throw new JadxRuntimeException("Failed to create temp file with suffix: " + suffix);
......
......@@ -209,7 +209,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
String str = getString(strIndex);
if (!isLastEnd) {
isLastEnd = true;
writer.add(">");
writer.add('>');
}
writer.attachSourceLine(lineNumber);
String escapedStr = StringUtils.escapeXML(str);
......@@ -235,13 +235,13 @@ public class BinaryXMLParser extends CommonBinaryParser {
int startNS = is.readInt32();
int startNSName = is.readInt32(); // actually is elementName...
if (!isLastEnd && !"ERROR".equals(currentTag)) {
writer.add(">");
writer.add('>');
}
isOneLine = true;
isLastEnd = false;
currentTag = deobfClassName(getString(startNSName));
currentTag = getValidTagAttributeName(currentTag);
writer.startLine("<").add(currentTag);
writer.startLine('<').add(currentTag);
writer.attachSourceLine(elementBegLineNumber);
int attributeStart = is.readInt16();
if (attributeStart != 0x14) {
......@@ -263,7 +263,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
writer.add(':');
writer.add(nsValue);
}
writer.add("=\"").add(StringUtils.escapeXML(entry.getKey())).add("\"");
writer.add("=\"").add(StringUtils.escapeXML(entry.getKey())).add('"');
}
}
boolean attrNewLine = attributeCount != 1 && ATTR_NEW_LINE;
......@@ -373,13 +373,13 @@ public class BinaryXMLParser extends CommonBinaryParser {
// reference custom processing
String name = styleMap.get(attrValData);
if (name != null) {
writer.add("@style/").add(name.replaceAll("_", "."));
writer.add("@style/").add(name.replace('_', '.'));
} else {
String resName = resNames.get(attrValData);
if (resName != null) {
writer.add("@");
writer.add('@');
if (resName.startsWith("id/")) {
writer.add("+");
writer.add('+');
}
writer.add(resName);
} else {
......@@ -424,7 +424,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
// if (elementNS != -1) {
// writer.add(getString(elementNS)).add(':');
// }
writer.add(elemName).add(">");
writer.add(elemName).add('>');
}
isLastEnd = true;
if (writer.getIndent() != 0) {
......
......@@ -49,7 +49,7 @@ public class ResContainer implements Comparable<ResContainer> {
}
public String getFileName() {
return name.replace("/", File.separator);
return name.replace('/', File.separatorChar);
}
public List<ResContainer> getSubFiles() {
......
......@@ -182,9 +182,9 @@ public class ResXmlGen {
cw.add('<').add(itemTag);
if (attrName != null && attrValue != null) {
if (typeName.equals("attr")) {
cw.add(' ').add("name=\"").add(attrName.replace("id.", "")).add("\" value=\"").add(attrValue).add("\"");
cw.add(' ').add("name=\"").add(attrName.replace("id.", "")).add("\" value=\"").add(attrValue).add('"');
} else if (typeName.equals("style")) {
cw.add(' ').add("name=\"").add(attrName.replace("attr.", "")).add("\"");
cw.add(' ').add("name=\"").add(attrName.replace("attr.", "")).add('"');
} else {
cw.add(' ').add(attrName).add("=\"").add(attrValue).add('"');
}
......
......@@ -44,8 +44,8 @@ public class JadxArgsValidatorOutDirsTest {
setOutDirs(null, null, null);
String inputFileBase = args.getInputFiles().get(0).getName().replace(".apk", "");
checkOutDirs(inputFileBase,
inputFileBase + "/" + JadxArgs.DEFAULT_SRC_DIR,
inputFileBase + "/" + JadxArgs.DEFAULT_RES_DIR);
inputFileBase + '/' + JadxArgs.DEFAULT_SRC_DIR,
inputFileBase + '/' + JadxArgs.DEFAULT_RES_DIR);
}
private void setOutDirs(String outDir, String srcDir, String resDir) {
......
......@@ -122,7 +122,7 @@ public class TypeCompareTest {
private void check(ArgType first, ArgType second, TypeCompareEnum expectedResult) {
TypeCompareEnum result = compare.compareTypes(first, second);
assertThat("Compare '" + first + "' vs '" + second + "'",
assertThat("Compare '" + first + "' vs '" + second + '\'',
result, is(expectedResult));
}
}
......@@ -317,7 +317,7 @@ public abstract class IntegrationTest extends TestUtils {
File temp = createTempFile(".jar");
try (JarOutputStream jo = new JarOutputStream(new FileOutputStream(temp))) {
for (File file : list) {
addFileToJar(jo, file, path + "/" + file.getName());
addFileToJar(jo, file, path + '/' + file.getName());
}
}
return temp;
......@@ -340,7 +340,7 @@ public abstract class IntegrationTest extends TestUtils {
private static File createTempDir(String prefix) throws IOException {
File baseDir = new File(System.getProperty("java.io.tmpdir"));
String baseName = prefix + "-" + System.nanoTime();
String baseName = prefix + '-' + System.nanoTime();
for (int counter = 1; counter < 1000; counter++) {
File tempDir = new File(baseDir, baseName + counter);
if (tempDir.mkdir()) {
......@@ -360,7 +360,7 @@ public abstract class IntegrationTest extends TestUtils {
File directory = new File(pkgResource.toURI());
String[] files = directory.list();
for (String file : files) {
String fullName = pkgName + "." + file;
String fullName = pkgName + '.' + file;
if (fullName.startsWith(clsName)) {
list.add(new File(directory, file));
}
......
......@@ -44,7 +44,7 @@ public abstract class SmaliTest extends IntegrationTest {
protected ClassNode getClassNodeFromSmaliFiles(String pkg, String testName, String clsName) {
File outDex = createTempFile(".dex");
compileSmali(outDex, collectSmaliFiles(pkg, testName));
return getClassNodeFromFile(outDex, pkg + "." + clsName);
return getClassNodeFromFile(outDex, pkg + '.' + clsName);
}
protected JadxDecompiler loadSmaliFile(String pkg, String smaliFileName) {
......
......@@ -32,7 +32,7 @@ class StringUtilsTest {
}
private void checkStringUnescape(String input, String result) {
assertThat(stringUtils.unescapeString(input), is("\"" + result + "\""));
assertThat(stringUtils.unescapeString(input), is('"' + result + '"'));
}
@Test
......@@ -47,6 +47,6 @@ class StringUtilsTest {
}
private void checkCharUnescape(char input, String result) {
assertThat(stringUtils.unescapeChar(input), is("'" + result + "'"));
assertThat(stringUtils.unescapeChar(input), is('\'' + result + '\''));
}
}
......@@ -18,7 +18,7 @@ public class TestStringBuilderElimination2 extends IntegrationTest {
public static class TestCls1 {
public String test() {
return new StringBuilder("[init]").append("a1").append('c').append(2).append(0l).append(1.0f).
return new StringBuilder("[init]").append("a1").append('c').append(2).append(0L).append(1.0f).
append(2.0d).append(true).toString();
}
}
......
package jadx.tests.integration.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.Test;
import jadx.NotYetImplemented;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
public class AnnotationsRenaming extends IntegrationTest {
public static class TestCls {
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public static @interface A {
int x();
}
@A(x = 5)
void test() {
}
}
@Test
@NotYetImplemented
public void test504() {
enableDeobfuscation();
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("public static @interface "));
assertThat(code, not(containsString("(x = 5)")));
}
}
......@@ -46,10 +46,10 @@ public class TestEnums extends IntegrationTest {
assertThat(code, containsLines(1, "public enum EmptyEnum {", "}"));
assertThat(code, containsLines(1,
"public enum EmptyEnum2 {",
indent(1) + ";",
indent(1) + ';',
"",
indent(1) + "public static void mth() {",
indent(1) + "}",
indent(1) + '}',
"}"));
assertThat(code, containsLines(1, "public enum Direction {",
......@@ -64,7 +64,7 @@ public class TestEnums extends IntegrationTest {
"",
indent(1) + "public String test() {",
indent(2) + "return \"\";",
indent(1) + "}",
indent(1) + '}',
"}"));
}
}
......@@ -38,12 +38,12 @@ public class TestEnums2 extends IntegrationTest {
indent(1) + "PLUS {",
indent(2) + "public int apply(int x, int y) {",
indent(3) + "return x + y;",
indent(2) + "}",
indent(2) + '}',
indent(1) + "},",
indent(1) + "MINUS {",
indent(2) + "public int apply(int x, int y) {",
indent(3) + "return x - y;",
indent(2) + "}",
indent(2) + '}',
indent(1) + "};",
"",
indent(1) + "public abstract int apply(int i, int i2);",
......
......@@ -7,7 +7,7 @@ import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestEnums3 extends IntegrationTest {
......@@ -30,9 +30,9 @@ public class TestEnums3 extends IntegrationTest {
}
public void check() {
assertTrue(Numbers.ONE.getNum() == 1);
assertTrue(Numbers.THREE.getNum() == 3);
assertTrue(Numbers.FOUR.getNum() == 4);
assertEquals(1, Numbers.ONE.getNum());
assertEquals(3, Numbers.THREE.getNum());
assertEquals(4, Numbers.FOUR.getNum());
}
}
......
......@@ -40,13 +40,13 @@ public class TestEnumsInterface extends IntegrationTest {
indent(1) + "PLUS {",
indent(2) + "public int apply(int x, int y) {",
indent(3) + "return x + y;",
indent(2) + "}",
indent(2) + '}',
indent(1) + "},",
indent(1) + "MINUS {",
indent(2) + "public int apply(int x, int y) {",
indent(3) + "return x - y;",
indent(2) + "}",
indent(1) + "}",
indent(2) + '}',
indent(1) + '}',
"}"
));
}
......
......@@ -37,9 +37,9 @@ public class TestAnonymousClass4 extends IntegrationTest {
String code = cls.getCode().toString();
assertThat(code, containsOne(indent(3) + "new Thread() {"));
assertThat(code, containsOne(indent(4) + "{"));
assertThat(code, containsOne(indent(4) + '{'));
assertThat(code, containsOne("f = 1;"));
assertThat(code, countString(2, indent(4) + "}"));
assertThat(code, countString(2, indent(4) + '}'));
assertThat(code, containsOne(indent(4) + "public void run() {"));
assertThat(code, containsOne("d = 7.5"));
assertThat(code, containsOne(indent(3) + "}.start();"));
......
......@@ -35,7 +35,7 @@ public class TestArrayForEach2 extends IntegrationTest {
indent(1) + "String t = s.trim();",
indent(1) + "if (t.length() > 0) {",
indent(2) + "System.out.println(t);",
indent(1) + "}",
indent(1) + '}',
"}"
));
}
......
......@@ -41,18 +41,18 @@ public class TestIssue13a extends IntegrationTest {
Field f = c.getField("CREATOR");
creator = (Parcelable.Creator) f.get(null);
} catch (IllegalAccessException e) {
Log.e(TAG, "1" + name + ", e: " + e);
throw new RuntimeException("2" + name);
Log.e(TAG, '1' + name + ", e: " + e);
throw new RuntimeException('2' + name);
} catch (ClassNotFoundException e) {
Log.e(TAG, "3" + name + ", e: " + e);
throw new RuntimeException("4" + name);
Log.e(TAG, '3' + name + ", e: " + e);
throw new RuntimeException('4' + name);
} catch (ClassCastException e) {
throw new RuntimeException("5" + name);
throw new RuntimeException('5' + name);
} catch (NoSuchFieldException e) {
throw new RuntimeException("6" + name);
throw new RuntimeException('6' + name);
}
if (creator == null) {
throw new RuntimeException("7" + name);
throw new RuntimeException('7' + name);
}
map.put(name, creator);
}
......@@ -95,7 +95,7 @@ public class TestIssue13a extends IntegrationTest {
String code = cls.getCode().toString();
for (int i = 1; i <= 7; i++) {
assertThat(code, containsOne("\"" + i + "\""));
assertThat(code, containsOne("'" + i + '\''));
}
// TODO: add additional checks
......
......@@ -38,7 +38,7 @@ public class TestSynchronized extends IntegrationTest {
assertThat(code, containsOne("return this.f"));
assertThat(code, containsOne("synchronized (this.o) {"));
assertThat(code, not(containsString(indent(3) + ";")));
assertThat(code, not(containsString(indent(3) + ';')));
assertThat(code, not(containsString("try {")));
assertThat(code, not(containsString("} catch (Throwable th) {")));
assertThat(code, not(containsString("throw th;")));
......
......@@ -43,8 +43,8 @@ public class TestTryCatch7 extends IntegrationTest {
private void check(String code, String excVarName, String catchExcVarName) {
assertThat(code, containsOne("Exception " + excVarName + " = new Exception();"));
assertThat(code, containsOne("} catch (Exception " + catchExcVarName + ") {"));
assertThat(code, containsOne(excVarName + " = " + catchExcVarName + ";"));
assertThat(code, containsOne(excVarName + " = " + catchExcVarName + ';'));
assertThat(code, containsOne(excVarName + ".printStackTrace();"));
assertThat(code, containsOne("return " + excVarName + ";"));
assertThat(code, containsOne("return " + excVarName + ';'));
}
}
......@@ -44,7 +44,7 @@ public class TestTryCatchFinally6 extends IntegrationTest {
"} finally {",
indent(1) + "if (is != null) {",
indent(2) + "is.close();",
indent(1) + "}",
indent(1) + '}',
"}"
));
}
......@@ -63,7 +63,7 @@ public class TestTryCatchFinally6 extends IntegrationTest {
"} finally {",
indent() + "if (fileInputStream != null) {",
indent() + indent() + "fileInputStream.close();",
indent() + "}",
indent() + '}',
"}"
));
}
......
......@@ -23,7 +23,7 @@ public class TestTryCatchInIf extends IntegrationTest {
} else {
key = Integer.parseInt(value);
}
return name + "=" + key;
return name + '=' + key;
} catch (NumberFormatException e) {
return "Failed to parse number";
}
......
......@@ -37,7 +37,7 @@ public class TestVariables4 extends IntegrationTest {
msg = "not extends AbstractTest";
}
System.err.println(">> "
+ (pass ? "PASS" : "FAIL") + "\t"
+ (pass ? "PASS" : "FAIL") + '\t'
+ clsName
+ (msg == null ? "" : "\t - " + msg));
if (exc != null) {
......
......@@ -211,7 +211,7 @@ public class JadxSettingsWindow extends JDialog {
private String getFontLabelStr() {
Font font = settings.getFont();
String fontStyleName = Utils.getFontStyleName(font.getStyle());
return NLS.str("preferences.font") + ": " + font.getFontName() + " " + fontStyleName + " " + font.getSize();
return NLS.str("preferences.font") + ": " + font.getFontName() + ' ' + fontStyleName + ' ' + font.getSize();
}
private SettingsGroup makeDecompilationGroup() {
......
......@@ -94,7 +94,7 @@ public class JMethod extends JNode {
@Override
public String makeLongString() {
String name = mth.getDeclaringClass().getFullName() + "." + makeBaseString();
String name = mth.getDeclaringClass().getFullName() + '.' + makeBaseString();
return Utils.typeFormat(name, getReturnType());
}
......
......@@ -66,7 +66,7 @@ public class JSources extends JNode {
pkg.getInnerPackages().clear();
pkg.getInnerPackages().addAll(innerPkg.getInnerPackages());
pkg.getClasses().addAll(innerPkg.getClasses());
pkg.setName(pkg.getName() + "." + innerPkg.getName());
pkg.setName(pkg.getName() + '.' + innerPkg.getName());
innerPkg.getInnerPackages().clear();
innerPkg.getClasses().clear();
......
......@@ -44,7 +44,7 @@ class SearchBar extends JToolBar {
public SearchBar(RSyntaxTextArea textArea) {
rTextArea = textArea;
JLabel findLabel = new JLabel(NLS.str("search.find") + ":");
JLabel findLabel = new JLabel(NLS.str("search.find") + ':');
add(findLabel);
searchField = new JTextField(30);
......
......@@ -126,13 +126,13 @@ public class CertificateManager {
StringBuilder builder = new StringBuilder();
if (x509cert != null) {
builder.append(generateHeader());
builder.append("\n");
builder.append('\n');
builder.append(generatePublicKey());
builder.append("\n");
builder.append('\n');
builder.append(generateSignature());
builder.append("\n");
builder.append('\n');
builder.append(generateFingerprint());
}
return builder.toString();
......@@ -150,7 +150,7 @@ public class CertificateManager {
}
static void append(StringBuilder str, String name, String value) {
str.append(name).append(": ").append(value).append("\n");
str.append(name).append(": ").append(value).append('\n');
}
public static String getThumbPrint(X509Certificate cert, String type)
......
......@@ -65,7 +65,7 @@ public class RunTests {
msg = "not extends AbstractTest";
}
System.err.println(">> "
+ (pass ? "PASS" : "FAIL") + "\t"
+ (pass ? "PASS" : "FAIL") + '\t'
+ clsName
+ (msg == null ? "" : "\t - " + msg));
if (exc != null) {
......
......@@ -12,7 +12,7 @@ public class TestStringProcessing extends AbstractTest {
public void testStringConcat() {
String s = "1";
assertEquals("a" + s, "a1");
assertEquals('a' + s, "a1");
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册