Fix bug for args in methods with generics
This commit is contained in:
@@ -263,7 +263,7 @@ public class MethodGen {
|
||||
}
|
||||
|
||||
private void makeFallbackMethod(CodeWriter code, MethodNode mth) {
|
||||
if (!mth.getAccessFlags().isStatic()) {
|
||||
if (mth.getThisArg() != null) {
|
||||
code.startLine(getFallbackMethodGen(mth).makeArgName(mth.getThisArg())).add(" = this;");
|
||||
}
|
||||
makeFallbackInsns(code, mth, mth.getInstructions(), true);
|
||||
|
||||
@@ -5,6 +5,7 @@ import jadx.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -421,6 +422,9 @@ public abstract class ArgType {
|
||||
}
|
||||
|
||||
private static List<ArgType> parseSignatureListInner(String str, boolean parsePrimitives) {
|
||||
if (str.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (str.equals("*")) {
|
||||
return Arrays.asList(UNKNOWN);
|
||||
}
|
||||
|
||||
@@ -154,29 +154,32 @@ public class MethodNode extends AttrNode implements ILoadable {
|
||||
LOG.warn("Signature parse error: {}", returnType);
|
||||
return false;
|
||||
}
|
||||
if (mthInfo.getArgumentsTypes().isEmpty()) {
|
||||
argsList = Collections.emptyList();
|
||||
return true;
|
||||
}
|
||||
|
||||
List<ArgType> argsTypes = ArgType.parseSignatureList(argsTypesStr);
|
||||
if (argsTypes == null)
|
||||
return false;
|
||||
|
||||
if (argsTypes.size() != mthInfo.getArgumentsTypes().size()) {
|
||||
if (argsTypes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (!mthInfo.isConstructor()) {
|
||||
LOG.warn("Wrong signature parse result: " + sign + " -> " + argsTypes
|
||||
+ ", not generic version: " + mthInfo.getArgumentsTypes());
|
||||
return false;
|
||||
} else if (getParentClass().getAccessFlags().isEnum()) {
|
||||
// TODO:
|
||||
argsTypes.add(0, mthInfo.getArgumentsTypes().get(1));
|
||||
argsTypes.add(0, mthInfo.getArgumentsTypes().get(0));
|
||||
argsTypes.add(1, mthInfo.getArgumentsTypes().get(1));
|
||||
} else {
|
||||
// add synthetic arg for outer class
|
||||
argsTypes.add(0, mthInfo.getArgumentsTypes().get(0));
|
||||
}
|
||||
if (argsTypes.size() != mthInfo.getArgumentsTypes().size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
initArguments(argsTypes);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public class Utils {
|
||||
case '>':
|
||||
case ',':
|
||||
case ' ':
|
||||
case '?':
|
||||
case '*':
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package jadx.samples;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -141,6 +142,28 @@ public class TestGenerics extends AbstractTest {
|
||||
}
|
||||
}
|
||||
|
||||
private class TestConstructor implements Enumeration<String> {
|
||||
private final TestGenerics a;
|
||||
|
||||
TestConstructor(TestGenerics a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreElements() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nextElement() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Enumeration<String> testThis() {
|
||||
return new TestConstructor(this);
|
||||
}
|
||||
|
||||
private List<String> test1(Map<String, String> map) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
String str = map.get("key");
|
||||
|
||||
Reference in New Issue
Block a user