Commit 207ce6cb authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

chore: fix "unused" warnings (PR #549)

parent 1d3e6ecb
...@@ -3,9 +3,6 @@ package jadx.core.dex.visitors.blocksmaker; ...@@ -3,9 +3,6 @@ package jadx.core.dex.visitors.blocksmaker;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jadx.core.dex.attributes.AType; import jadx.core.dex.attributes.AType;
import jadx.core.dex.nodes.BlockNode; import jadx.core.dex.nodes.BlockNode;
import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.MethodNode;
...@@ -16,8 +13,6 @@ import jadx.core.utils.BlockUtils; ...@@ -16,8 +13,6 @@ import jadx.core.utils.BlockUtils;
public class BlockFinish extends AbstractVisitor { public class BlockFinish extends AbstractVisitor {
private static final Logger LOG = LoggerFactory.getLogger(BlockFinish.class);
@Override @Override
public void visit(MethodNode mth) { public void visit(MethodNode mth) {
if (mth.isNoCode()) { if (mth.isNoCode()) {
...@@ -33,7 +28,7 @@ public class BlockFinish extends AbstractVisitor { ...@@ -33,7 +28,7 @@ public class BlockFinish extends AbstractVisitor {
} }
/** /**
* For evey exception handler must be only one splitter block, * For every exception handler must be only one splitter block,
* select correct one and remove others if necessary. * select correct one and remove others if necessary.
*/ */
private static void fixSplitterBlock(MethodNode mth, BlockNode block) { private static void fixSplitterBlock(MethodNode mth, BlockNode block) {
......
...@@ -4,9 +4,6 @@ import java.util.ArrayList; ...@@ -4,9 +4,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.android.dex.Dex.Section; import com.android.dex.Dex.Section;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jadx.core.dex.attributes.nodes.SourceFileAttr; import jadx.core.dex.attributes.nodes.SourceFileAttr;
import jadx.core.dex.instructions.args.RegisterArg; import jadx.core.dex.instructions.args.RegisterArg;
import jadx.core.dex.nodes.DexNode; import jadx.core.dex.nodes.DexNode;
...@@ -15,7 +12,6 @@ import jadx.core.dex.nodes.MethodNode; ...@@ -15,7 +12,6 @@ import jadx.core.dex.nodes.MethodNode;
import jadx.core.utils.exceptions.DecodeException; import jadx.core.utils.exceptions.DecodeException;
public class DebugInfoParser { public class DebugInfoParser {
private static final Logger LOG = LoggerFactory.getLogger(DebugInfoParser.class);
private static final int DBG_END_SEQUENCE = 0x00; private static final int DBG_END_SEQUENCE = 0x00;
private static final int DBG_ADVANCE_PC = 0x01; private static final int DBG_ADVANCE_PC = 0x01;
private static final int DBG_ADVANCE_LINE = 0x02; private static final int DBG_ADVANCE_LINE = 0x02;
......
...@@ -31,6 +31,7 @@ import jadx.core.xmlgen.entry.ValuesParser; ...@@ -31,6 +31,7 @@ import jadx.core.xmlgen.entry.ValuesParser;
Check Element chunk size Check Element chunk size
*/ */
@SuppressWarnings("unused")
public class BinaryXMLParser extends CommonBinaryParser { public class BinaryXMLParser extends CommonBinaryParser {
private static final Logger LOG = LoggerFactory.getLogger(BinaryXMLParser.class); private static final Logger LOG = LoggerFactory.getLogger(BinaryXMLParser.class);
......
...@@ -11,6 +11,7 @@ public class CommonBinaryParser extends ParserConstants { ...@@ -11,6 +11,7 @@ public class CommonBinaryParser extends ParserConstants {
return parseStringPoolNoType(); return parseStringPoolNoType();
} }
@SuppressWarnings("unused")
protected String[] parseStringPoolNoType() throws IOException { protected String[] parseStringPoolNoType() throws IOException {
long start = is.getPos() - 2; long start = is.getPos() - 2;
is.checkInt16(0x001c, "String pool header size not 0x001c"); is.checkInt16(0x001c, "String pool header size not 0x001c");
......
...@@ -164,6 +164,7 @@ public class ResTableParser extends CommonBinaryParser { ...@@ -164,6 +164,7 @@ public class ResTableParser extends CommonBinaryParser {
return pkg; return pkg;
} }
@SuppressWarnings("unused")
private void parseTypeSpecChunk() throws IOException { private void parseTypeSpecChunk() throws IOException {
is.checkInt16(0x0010, "Unexpected type spec header size"); is.checkInt16(0x0010, "Unexpected type spec header size");
/*int size = */ /*int size = */
......
...@@ -14,12 +14,13 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -14,12 +14,13 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestWrongCode extends IntegrationTest { public class TestWrongCode extends IntegrationTest {
public static class TestCls { public static class TestCls {
private int test() { @SuppressWarnings("null")
public int test() {
int[] a = null; int[] a = null;
return a.length; return a.length;
} }
private int test2(int a) { public int test2(int a) {
if (a == 0) { if (a == 0) {
} }
return a; return a;
......
...@@ -13,9 +13,9 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -13,9 +13,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestArith3 extends IntegrationTest { public class TestArith3 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private int vp; public int vp;
private void test(byte[] buffer) { public void test(byte[] buffer) {
int n = ((buffer[3] & 255) + 4) + ((buffer[2] & 15) << 8); int n = ((buffer[3] & 255) + 4) + ((buffer[2] & 15) << 8);
while (n + 4 < buffer.length) { while (n + 4 < buffer.length) {
int c = buffer[n] & 255; int c = buffer[n] & 255;
......
...@@ -37,7 +37,6 @@ public class TestLineNumbers2 extends IntegrationTest { ...@@ -37,7 +37,6 @@ public class TestLineNumbers2 extends IntegrationTest {
public void test() { public void test() {
ClassNode cls = getClassNode(TestCls.class); ClassNode cls = getClassNode(TestCls.class);
CodeWriter codeWriter = cls.getCode(); CodeWriter codeWriter = cls.getCode();
String code = codeWriter.toString();
Map<Integer, Integer> lineMapping = codeWriter.getLineMapping(); Map<Integer, Integer> lineMapping = codeWriter.getLineMapping();
assertEquals("{8=18, 11=22, 12=23, 13=24, 14=28, 16=25, 17=26, 18=28, 21=31, 22=32}", assertEquals("{8=18, 11=22, 12=23, 13=24, 14=28, 16=25, 17=26, 18=28, 21=31, 22=32}",
......
...@@ -16,8 +16,8 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -16,8 +16,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestGenerics2 extends IntegrationTest { public class TestGenerics2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private static class ItemReference<V> extends WeakReference<V> { public static class ItemReference<V> extends WeakReference<V> {
private Object id; public Object id;
public ItemReference(V item, Object objId, ReferenceQueue<? super V> queue) { public ItemReference(V item, Object objId, ReferenceQueue<? super V> queue) {
super(item, queue); super(item, queue);
......
...@@ -24,7 +24,7 @@ public class TestIssue86 extends IntegrationTest { ...@@ -24,7 +24,7 @@ public class TestIssue86 extends IntegrationTest {
private static final String WEATHER_TAG = "weather-tag"; private static final String WEATHER_TAG = "weather-tag";
private static final String DESC_TAG = "desc-tag"; private static final String DESC_TAG = "desc-tag";
private List<Day> test(String response) { public List<Day> test(String response) {
List<Day> reportList = new ArrayList<>(); List<Day> reportList = new ArrayList<>();
try { try {
System.out.println(response); System.out.println(response);
......
...@@ -16,8 +16,8 @@ public class TestAnonymousClass12 extends IntegrationTest { ...@@ -16,8 +16,8 @@ public class TestAnonymousClass12 extends IntegrationTest {
public abstract void doSomething(); public abstract void doSomething();
} }
private BasicAbstract outer; public BasicAbstract outer;
private BasicAbstract inner; public BasicAbstract inner;
public void test() { public void test() {
outer = new BasicAbstract() { outer = new BasicAbstract() {
......
...@@ -13,7 +13,7 @@ public class TestAnonymousClass2 extends IntegrationTest { ...@@ -13,7 +13,7 @@ public class TestAnonymousClass2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
public static class Inner { public static class Inner {
private int f; public int f;
public Runnable test() { public Runnable test() {
return new Runnable() { return new Runnable() {
...@@ -27,6 +27,7 @@ public class TestAnonymousClass2 extends IntegrationTest { ...@@ -27,6 +27,7 @@ public class TestAnonymousClass2 extends IntegrationTest {
public Runnable test2() { public Runnable test2() {
return new Runnable() { return new Runnable() {
@Override @Override
@SuppressWarnings("unused")
public void run() { public void run() {
Object obj = Inner.this; Object obj = Inner.this;
} }
......
...@@ -13,7 +13,7 @@ public class TestAnonymousClass3 extends IntegrationTest { ...@@ -13,7 +13,7 @@ public class TestAnonymousClass3 extends IntegrationTest {
public static class TestCls { public static class TestCls {
public static class Inner { public static class Inner {
private int f; private int f;
private double d; public double d;
public void test() { public void test() {
new Thread() { new Thread() {
......
...@@ -12,6 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -12,6 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestAnonymousClass4 extends IntegrationTest { public class TestAnonymousClass4 extends IntegrationTest {
public static class TestCls { public static class TestCls {
@SuppressWarnings("unused")
public static class Inner { public static class Inner {
private int f; private int f;
private double d; private double d;
......
...@@ -19,7 +19,7 @@ public class TestInnerClass4 extends IntegrationTest { ...@@ -19,7 +19,7 @@ public class TestInnerClass4 extends IntegrationTest {
} }
} }
private String test() { public String test() {
return new C().c; return new C().c;
} }
} }
......
...@@ -17,6 +17,7 @@ public class TestOuterConstructorCall extends IntegrationTest { ...@@ -17,6 +17,7 @@ public class TestOuterConstructorCall extends IntegrationTest {
} }
private class Inner { private class Inner {
@SuppressWarnings("unused")
private TestCls test() { private TestCls test() {
return new TestCls(this); return new TestCls(this);
} }
......
...@@ -16,7 +16,7 @@ public class TestInvoke1 extends IntegrationTest { ...@@ -16,7 +16,7 @@ public class TestInvoke1 extends IntegrationTest {
private A is; private A is;
private C test(int start) throws IOException { public C test(int start) throws IOException {
int id = is.readInt32(); int id = is.readInt32();
String name = is.readString16Fixed(128); String name = is.readString16Fixed(128);
......
...@@ -17,7 +17,7 @@ public class TestInvokeInCatch extends IntegrationTest { ...@@ -17,7 +17,7 @@ public class TestInvokeInCatch extends IntegrationTest {
public static class TestCls { public static class TestCls {
private static final String TAG = "TAG"; private static final String TAG = "TAG";
private void test(int[] a, int b) { public void test(int[] a, int b) {
try { try {
exc(); exc();
} catch (IOException e) { } catch (IOException e) {
......
...@@ -7,7 +7,6 @@ import jadx.tests.api.IntegrationTest; ...@@ -7,7 +7,6 @@ import jadx.tests.api.IntegrationTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne; import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
public class TestSuperInvokeWithGenerics extends IntegrationTest { public class TestSuperInvokeWithGenerics extends IntegrationTest {
......
...@@ -12,7 +12,7 @@ public class TestArrayForEach extends IntegrationTest { ...@@ -12,7 +12,7 @@ public class TestArrayForEach extends IntegrationTest {
public static class TestCls { public static class TestCls {
private int test(int[] a) { public int test(int[] a) {
int sum = 0; int sum = 0;
for (int n : a) { for (int n : a) {
sum += n; sum += n;
......
...@@ -13,7 +13,7 @@ import static org.hamcrest.Matchers.not; ...@@ -13,7 +13,7 @@ import static org.hamcrest.Matchers.not;
public class TestArrayForEach2 extends IntegrationTest { public class TestArrayForEach2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private void test(String str) { public void test(String str) {
for (String s : str.split("\n")) { for (String s : str.split("\n")) {
String t = s.trim(); String t = s.trim();
if (t.length() > 0) { if (t.length() > 0) {
......
...@@ -13,7 +13,7 @@ public class TestArrayForEachNegative extends IntegrationTest { ...@@ -13,7 +13,7 @@ public class TestArrayForEachNegative extends IntegrationTest {
public static class TestCls { public static class TestCls {
private int test(int[] a, int[] b) { public int test(int[] a, int[] b) {
int sum = 0; int sum = 0;
for (int i = 0; i < a.length; i += 2) { for (int i = 0; i < a.length; i += 2) {
sum += a[i]; sum += a[i];
......
...@@ -12,9 +12,9 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -12,9 +12,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestBreakInLoop extends IntegrationTest { public class TestBreakInLoop extends IntegrationTest {
public static class TestCls { public static class TestCls {
private int f; public int f;
private void test(int[] a, int b) { public void test(int[] a, int b) {
for (int i = 0; i < a.length; i++) { for (int i = 0; i < a.length; i++) {
a[i]++; a[i]++;
if (i < b) { if (i < b) {
......
...@@ -11,9 +11,9 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -11,9 +11,9 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestContinueInLoop extends IntegrationTest { public class TestContinueInLoop extends IntegrationTest {
public static class TestCls { public static class TestCls {
private int f; public int f;
private void test(int[] a, int b) { public void test(int[] a, int b) {
for (int i = 0; i < a.length; i++) { for (int i = 0; i < a.length; i++) {
int v = a[i]; int v = a[i];
if (v < b) { if (v < b) {
......
...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestIterableForEach extends IntegrationTest { public class TestIterableForEach extends IntegrationTest {
public static class TestCls { public static class TestCls {
private String test(Iterable<String> a) { public String test(Iterable<String> a) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String s : a) { for (String s : a) {
sb.append(s); sb.append(s);
......
...@@ -16,7 +16,7 @@ public class TestIterableForEach3 extends IntegrationTest { ...@@ -16,7 +16,7 @@ public class TestIterableForEach3 extends IntegrationTest {
private Set<T> a; private Set<T> a;
private Set<T> b; private Set<T> b;
private void test(T str) { public void test(T str) {
Set<T> set = str.length() == 1 ? a : b; Set<T> set = str.length() == 1 ? a : b;
for (T s : set) { for (T s : set) {
if (s.length() == str.length()) { if (s.length() == str.length()) {
......
...@@ -16,7 +16,7 @@ public class TestLoopCondition extends IntegrationTest { ...@@ -16,7 +16,7 @@ public class TestLoopCondition extends IntegrationTest {
private void setEnabled(boolean r1z) { private void setEnabled(boolean r1z) {
} }
private void testIfInLoop() { public void testIfInLoop() {
int j = 0; int j = 0;
for (int i = 0; i < f.length(); i++) { for (int i = 0; i < f.length(); i++) {
char ch = f.charAt(i); char ch = f.charAt(i);
...@@ -31,7 +31,7 @@ public class TestLoopCondition extends IntegrationTest { ...@@ -31,7 +31,7 @@ public class TestLoopCondition extends IntegrationTest {
setEnabled(false); setEnabled(false);
} }
private void testMoreComplexIfInLoop(java.util.ArrayList<String> list) throws Exception { public void testMoreComplexIfInLoop(java.util.ArrayList<String> list) throws Exception {
for (int i = 0; i != 16 && i < 255; i++) { for (int i = 0; i != 16 && i < 255; i++) {
list.set(i, "ABC"); list.set(i, "ABC");
if (i == 128) { if (i == 128) {
......
...@@ -13,7 +13,7 @@ import static org.hamcrest.Matchers.anyOf; ...@@ -13,7 +13,7 @@ import static org.hamcrest.Matchers.anyOf;
public class TestLoopCondition5 extends SmaliTest { public class TestLoopCondition5 extends SmaliTest {
public static class TestCls { public static class TestCls {
private static int lastIndexOf(int[] array, int target, int start, int end) { public static int lastIndexOf(int[] array, int target, int start, int end) {
for (int i = end - 1; i >= start; i--) { for (int i = end - 1; i >= start; i--) {
if (array[i] == target) { if (array[i] == target) {
return i; return i;
......
...@@ -14,7 +14,7 @@ public class TestLoopConditionInvoke extends IntegrationTest { ...@@ -14,7 +14,7 @@ public class TestLoopConditionInvoke extends IntegrationTest {
private static final char STOP_CHAR = 0; private static final char STOP_CHAR = 0;
private int pos; private int pos;
private boolean test(char lastChar) { public boolean test(char lastChar) {
int startPos = pos; int startPos = pos;
char ch; char ch;
while ((ch = next()) != STOP_CHAR) { while ((ch = next()) != STOP_CHAR) {
......
...@@ -13,7 +13,7 @@ public class TestLoopDetection extends IntegrationTest { ...@@ -13,7 +13,7 @@ public class TestLoopDetection extends IntegrationTest {
public static class TestCls { public static class TestCls {
private void test(int[] a, int b) { public void test(int[] a, int b) {
int i = 0; int i = 0;
while (i < a.length && i < b) { while (i < a.length && i < b) {
a[i]++; a[i]++;
......
...@@ -13,7 +13,7 @@ public class TestLoopDetection3 extends IntegrationTest { ...@@ -13,7 +13,7 @@ public class TestLoopDetection3 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private void test(TestCls parent, int pos) { public void test(TestCls parent, int pos) {
Object item; Object item;
while (--pos >= 0) { while (--pos >= 0) {
item = parent.get(pos); item = parent.get(pos);
......
...@@ -16,7 +16,7 @@ public class TestLoopDetection4 extends IntegrationTest { ...@@ -16,7 +16,7 @@ public class TestLoopDetection4 extends IntegrationTest {
private Iterator<String> iterator; private Iterator<String> iterator;
private SomeCls filter; private SomeCls filter;
private String test() { public String test() {
while (iterator.hasNext()) { while (iterator.hasNext()) {
String next = iterator.next(); String next = iterator.next();
String filtered = filter.filter(next); String filtered = filter.filter(next);
......
...@@ -14,7 +14,7 @@ public class TestNestedLoops extends IntegrationTest { ...@@ -14,7 +14,7 @@ public class TestNestedLoops extends IntegrationTest {
public static class TestCls { public static class TestCls {
private void test(List<String> l1, List<String> l2) { public void test(List<String> l1, List<String> l2) {
for (String s1 : l1) { for (String s1 : l1) {
for (String s2 : l2) { for (String s2 : l2) {
if (s1.equals(s2)) { if (s1.equals(s2)) {
......
...@@ -14,7 +14,7 @@ public class TestNestedLoops2 extends IntegrationTest { ...@@ -14,7 +14,7 @@ public class TestNestedLoops2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private boolean test(List<String> list) { public boolean test(List<String> list) {
int j = 0; int j = 0;
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
String s = list.get(i); String s = list.get(i);
......
...@@ -21,7 +21,7 @@ public class TestNameAssign2 extends IntegrationTest { ...@@ -21,7 +21,7 @@ public class TestNameAssign2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private static void test(MethodNode mth, int regNum, LiveVarAnalysis la) { public static void test(MethodNode mth, int regNum, LiveVarAnalysis la) {
List<BlockNode> blocks = mth.getBasicBlocks(); List<BlockNode> blocks = mth.getBasicBlocks();
int blocksCount = blocks.size(); int blocksCount = blocks.size();
BitSet hasPhi = new BitSet(blocksCount); BitSet hasPhi = new BitSet(blocksCount);
......
...@@ -19,7 +19,7 @@ public class TestDefConstructorNotRemoved extends IntegrationTest { ...@@ -19,7 +19,7 @@ public class TestDefConstructorNotRemoved extends IntegrationTest {
} }
public static class A { public static class A {
private final String s; public final String s;
public A() { public A() {
s = "a"; s = "a";
......
...@@ -21,11 +21,11 @@ public class TestFieldInit extends IntegrationTest { ...@@ -21,11 +21,11 @@ public class TestFieldInit extends IntegrationTest {
public class A { public class A {
} }
private static List<String> s = new ArrayList<>(); public static List<String> s = new ArrayList<>();
private A a = new A(); public A a = new A();
private int i = 1 + Random.class.getSimpleName().length(); public int i = 1 + Random.class.getSimpleName().length();
private int n = 0; public int n = 0;
public TestCls(int z) { public TestCls(int z) {
this.n = z; this.n = z;
......
...@@ -17,13 +17,13 @@ public class TestFieldInit2 extends IntegrationTest { ...@@ -17,13 +17,13 @@ public class TestFieldInit2 extends IntegrationTest {
void doSomething(); void doSomething();
} }
private BasicAbstract x = new BasicAbstract() { public BasicAbstract x = new BasicAbstract() {
@Override @Override
public void doSomething() { public void doSomething() {
y = 1; y = 1;
} }
}; };
private int y = 0; public int y = 0;
public TestCls() { public TestCls() {
} }
......
...@@ -15,7 +15,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -15,7 +15,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestFieldInitInTryCatch extends IntegrationTest { public class TestFieldInitInTryCatch extends IntegrationTest {
public static class TestCls { public static class TestCls {
private static final URL a; public static final URL a;
static { static {
try { try {
...@@ -27,7 +27,7 @@ public class TestFieldInitInTryCatch extends IntegrationTest { ...@@ -27,7 +27,7 @@ public class TestFieldInitInTryCatch extends IntegrationTest {
} }
public static class TestCls2 { public static class TestCls2 {
private static final URL[] a; public static final URL[] a;
static { static {
try { try {
...@@ -39,7 +39,7 @@ public class TestFieldInitInTryCatch extends IntegrationTest { ...@@ -39,7 +39,7 @@ public class TestFieldInitInTryCatch extends IntegrationTest {
} }
public static class TestCls3 { public static class TestCls3 {
private static final String[] a; public static final String[] a;
static { static {
try { try {
...@@ -58,7 +58,7 @@ public class TestFieldInitInTryCatch extends IntegrationTest { ...@@ -58,7 +58,7 @@ public class TestFieldInitInTryCatch extends IntegrationTest {
ClassNode cls = getClassNode(TestCls.class); ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, containsOne("private static final URL a;")); assertThat(code, containsOne("public static final URL a;"));
assertThat(code, containsOne("a = new URL(\"http://www.example.com/\");")); assertThat(code, containsOne("a = new URL(\"http://www.example.com/\");"));
assertThat(code, containsLines(2, assertThat(code, containsLines(2,
"try {", "try {",
...@@ -82,6 +82,6 @@ public class TestFieldInitInTryCatch extends IntegrationTest { ...@@ -82,6 +82,6 @@ public class TestFieldInitInTryCatch extends IntegrationTest {
ClassNode cls = getClassNode(TestCls3.class); ClassNode cls = getClassNode(TestCls3.class);
String code = cls.getCode().toString(); String code = cls.getCode().toString();
assertThat(code, containsOne("private static final String[] a = new String[]{\"a\"};")); assertThat(code, containsOne("public static final String[] a = new String[]{\"a\"};"));
} }
} }
...@@ -15,7 +15,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -15,7 +15,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestIfInTry extends IntegrationTest { public class TestIfInTry extends IntegrationTest {
public static class TestCls { public static class TestCls {
private File dir; public File dir;
public int test() { public int test() {
try { try {
......
...@@ -12,7 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -12,7 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestIfTryInCatch extends IntegrationTest { public class TestIfTryInCatch extends IntegrationTest {
public static class TestCls { public static class TestCls {
private Exception exception; public Exception exception;
private java.lang.Object data; private java.lang.Object data;
public java.lang.Object test(final Object obj) { public java.lang.Object test(final Object obj) {
......
...@@ -22,9 +22,9 @@ public class TestIssue13b extends IntegrationTest { ...@@ -22,9 +22,9 @@ public class TestIssue13b extends IntegrationTest {
private static final String PROPERTIES_FILE = ""; private static final String PROPERTIES_FILE = "";
private static final String TAG = ""; private static final String TAG = "";
private final CountDownLatch mInitializedLatch = new CountDownLatch(1); private final CountDownLatch mInitializedLatch = new CountDownLatch(1);
private int mC2KServerPort = 0; public int mC2KServerPort = 0;
private String mSuplServerHost = ""; private String mSuplServerHost = "";
private int mSuplServerPort = 0; public int mSuplServerPort = 0;
private String mC2KServerHost = ""; private String mC2KServerHost = "";
public TestCls() { public TestCls() {
......
...@@ -8,7 +8,6 @@ import com.android.dx.io.instructions.ShortArrayCodeInput; ...@@ -8,7 +8,6 @@ import com.android.dx.io.instructions.ShortArrayCodeInput;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode; import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.DexNode;
import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.MethodNode;
import jadx.core.utils.exceptions.DecodeException; import jadx.core.utils.exceptions.DecodeException;
import jadx.tests.api.IntegrationTest; import jadx.tests.api.IntegrationTest;
...@@ -20,8 +19,7 @@ public class TestLoopInTry2 extends IntegrationTest { ...@@ -20,8 +19,7 @@ public class TestLoopInTry2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private MethodNode method; private MethodNode method;
private DexNode dex; public DecodedInstruction[] insnArr;
private DecodedInstruction[] insnArr;
public void test(Code mthCode) throws DecodeException { public void test(Code mthCode) throws DecodeException {
short[] encodedInstructions = mthCode.getInstructions(); short[] encodedInstructions = mthCode.getInstructions();
......
...@@ -13,6 +13,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -13,6 +13,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestSynchronized2 extends IntegrationTest { public class TestSynchronized2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
@SuppressWarnings("unused")
private static synchronized boolean test(Object obj) { private static synchronized boolean test(Object obj) {
return obj.toString() != null; return obj.toString() != null;
} }
......
...@@ -12,7 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -12,7 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestNestedTryCatch extends IntegrationTest { public class TestNestedTryCatch extends IntegrationTest {
public static class TestCls { public static class TestCls {
private void f() { public void f() {
try { try {
Thread.sleep(1); Thread.sleep(1);
try { try {
......
...@@ -12,7 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -12,7 +12,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestTryCatch extends IntegrationTest { public class TestTryCatch extends IntegrationTest {
public static class TestCls { public static class TestCls {
private void f() { public void f() {
try { try {
Thread.sleep(50); Thread.sleep(50);
} catch (InterruptedException e) { } catch (InterruptedException e) {
......
...@@ -13,7 +13,7 @@ public class TestTryCatch2 extends IntegrationTest { ...@@ -13,7 +13,7 @@ public class TestTryCatch2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private final static Object obj = new Object(); private final static Object obj = new Object();
private static boolean test() { public static boolean test() {
try { try {
synchronized (obj) { synchronized (obj) {
obj.wait(5); obj.wait(5);
......
...@@ -16,7 +16,8 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -16,7 +16,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestTryCatch4 extends IntegrationTest { public class TestTryCatch4 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private Object test(Object obj) { @SuppressWarnings({ "resource", "unused" })
public Object test(Object obj) {
FileOutputStream output = null; FileOutputStream output = null;
try { try {
output = new FileOutputStream(new File("f")); output = new FileOutputStream(new File("f"));
......
...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestTryCatch7 extends IntegrationTest { public class TestTryCatch7 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private Exception test() { public Exception test() {
Exception e = new Exception(); Exception e = new Exception();
try { try {
Thread.sleep(50); Thread.sleep(50);
......
...@@ -15,7 +15,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -15,7 +15,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestTryCatchFinally5 extends IntegrationTest { public class TestTryCatchFinally5 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private <E> List<E> test(A a, B<E> b) { public <E> List<E> test(A a, B<E> b) {
C c = p(a); C c = p(a);
if (c == null) { if (c == null) {
return null; return null;
......
...@@ -16,7 +16,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -16,7 +16,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestTryCatchFinally8 extends IntegrationTest { public class TestTryCatchFinally8 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private Object test(Object obj) { public Object test(Object obj) {
File file = new File("r"); File file = new File("r");
FileOutputStream output = null; FileOutputStream output = null;
try { try {
......
...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestGenerics extends IntegrationTest { public class TestGenerics extends IntegrationTest {
public static class TestCls<T> { public static class TestCls<T> {
private T data; public T data;
public TestCls<T> data(T t) { public TestCls<T> data(T t) {
this.data = t; this.data = t;
......
...@@ -25,7 +25,7 @@ public class TestTypeInheritance extends IntegrationTest { ...@@ -25,7 +25,7 @@ public class TestTypeInheritance extends IntegrationTest {
public void b() {} public void b() {}
} }
private static void test(boolean z) { public static void test(boolean z) {
IBase impl; IBase impl;
if (z) { if (z) {
impl = new A(); impl = new A();
......
...@@ -14,7 +14,7 @@ public class TestTypeResolver2 extends IntegrationTest { ...@@ -14,7 +14,7 @@ public class TestTypeResolver2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private static boolean test(Object obj) throws IOException { public static boolean test(Object obj) throws IOException {
if (obj != null) { if (obj != null) {
return true; return true;
} }
......
...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestTypeResolver6 extends IntegrationTest { public class TestTypeResolver6 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private final Object obj; public final Object obj;
public TestCls(boolean b) { public TestCls(boolean b) {
this.obj = b ? this : makeObj(); this.obj = b ? this : makeObj();
......
...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -11,7 +11,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestTypeResolver6a extends IntegrationTest { public class TestTypeResolver6a extends IntegrationTest {
public static class TestCls implements Runnable { public static class TestCls implements Runnable {
private final Runnable runnable; public final Runnable runnable;
public TestCls(boolean b) { public TestCls(boolean b) {
this.runnable = b ? this : makeRunnable(); this.runnable = b ? this : makeRunnable();
......
...@@ -15,7 +15,7 @@ public class TestDontInlineThis extends IntegrationTest { ...@@ -15,7 +15,7 @@ public class TestDontInlineThis extends IntegrationTest {
public static class TestCls { public static class TestCls {
public int field = new Random().nextInt(); public int field = new Random().nextInt();
private TestCls test() { public TestCls test() {
TestCls res; TestCls res;
if (field == 7) { if (field == 7) {
res = this; res = this;
......
...@@ -15,7 +15,7 @@ public class TestInlineThis extends IntegrationTest { ...@@ -15,7 +15,7 @@ public class TestInlineThis extends IntegrationTest {
public static class TestCls { public static class TestCls {
public int field; public int field;
private void test() { public void test() {
TestCls something = this; TestCls something = this;
something.method(); something.method();
something.field = 123; something.field = 123;
......
...@@ -17,7 +17,7 @@ public class TestInlineThis2 extends IntegrationTest { ...@@ -17,7 +17,7 @@ public class TestInlineThis2 extends IntegrationTest {
public static class TestCls { public static class TestCls {
public int field; public int field;
private void test() { public void test() {
TestCls thisVar = this; TestCls thisVar = this;
if (Objects.isNull(thisVar)) { if (Objects.isNull(thisVar)) {
System.out.println("null"); System.out.println("null");
......
...@@ -14,7 +14,7 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -14,7 +14,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
public class TestVariables4 extends IntegrationTest { public class TestVariables4 extends IntegrationTest {
public static class TestCls { public static class TestCls {
private static boolean runTest(String clsName) { public static boolean runTest(String clsName) {
try { try {
boolean pass = false; boolean pass = false;
String msg = null; String msg = null;
......
...@@ -13,7 +13,7 @@ public class TestGenerics extends AbstractTest { ...@@ -13,7 +13,7 @@ public class TestGenerics extends AbstractTest {
public Class<?>[] classes; public Class<?>[] classes;
public interface MyComparable<T> { public interface MyComparable<T> {
public int compareTo(T o); int compareTo(T o);
} }
public static class GenericClass implements MyComparable<String> { public static class GenericClass implements MyComparable<String> {
...@@ -38,9 +38,9 @@ public class TestGenerics extends AbstractTest { ...@@ -38,9 +38,9 @@ public class TestGenerics extends AbstractTest {
public static Box<Integer> integerBox = new Box<>(); public static Box<Integer> integerBox = new Box<>();
public interface Pair<K, LongGenericType> { public interface Pair<K, LongGenericType> {
public K getKey(); K getKey();
public LongGenericType getValue(); LongGenericType getValue();
} }
public static class OrderedPair<K, V> implements Pair<K, V> { public static class OrderedPair<K, V> implements Pair<K, V> {
...@@ -133,7 +133,7 @@ public class TestGenerics extends AbstractTest { ...@@ -133,7 +133,7 @@ public class TestGenerics extends AbstractTest {
public class Node<T extends Comparable<T>> { public class Node<T extends Comparable<T>> {
private final T data; private final T data;
private final Node<T> next; public final Node<T> next;
public Node(T data, Node<T> next) { public Node(T data, Node<T> next) {
this.data = data; this.data = data;
...@@ -145,8 +145,8 @@ public class TestGenerics extends AbstractTest { ...@@ -145,8 +145,8 @@ public class TestGenerics extends AbstractTest {
} }
} }
private class TestConstructor implements Enumeration<String> { public class TestConstructor implements Enumeration<String> {
private final TestGenerics a; public final TestGenerics a;
TestConstructor(TestGenerics a) { TestConstructor(TestGenerics a) {
this.a = a; this.a = a;
......
...@@ -2,7 +2,7 @@ package jadx.samples; ...@@ -2,7 +2,7 @@ package jadx.samples;
public class TestTypeResolver extends AbstractTest { public class TestTypeResolver extends AbstractTest {
private final int f1; public final int f1;
public TestTypeResolver() { public TestTypeResolver() {
this.f1 = 2; this.f1 = 2;
......
...@@ -21,11 +21,11 @@ public class TestTypeResolver2 extends AbstractTest { ...@@ -21,11 +21,11 @@ public class TestTypeResolver2 extends AbstractTest {
} }
} }
private static void doPrint(String s1) { public static void doPrint(String s1) {
fail(); fail();
} }
private static void doPrint(Integer s1) { public static void doPrint(Integer s1) {
fail(); fail();
} }
...@@ -43,6 +43,6 @@ public class TestTypeResolver2 extends AbstractTest { ...@@ -43,6 +43,6 @@ public class TestTypeResolver2 extends AbstractTest {
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
(new TestTypeResolver2()).testRun(); new TestTypeResolver2().testRun();
} }
} }
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