Commit 03da35b2 authored by Skylot's avatar Skylot

core: fix wildcard signature processing

parent 3ccab60f
......@@ -174,7 +174,7 @@ public abstract class ArgType {
private final int bounds;
public WildcardType(ArgType obj, int bound) {
super(obj.getObject());
super(ArgType.OBJECT.getObject());
this.type = obj;
this.bounds = bound;
}
......@@ -205,7 +205,8 @@ public abstract class ArgType {
@Override
boolean internalEquals(Object obj) {
return super.internalEquals(obj)
&& bounds == ((WildcardType) obj).bounds;
&& bounds == ((WildcardType) obj).bounds
&& type.equals(((WildcardType) obj).type);
}
@Override
......@@ -213,7 +214,7 @@ public abstract class ArgType {
if (bounds == 0) {
return "?";
}
return "? " + (bounds == -1 ? "super" : "extends") + " " + super.toString();
return "? " + (bounds == -1 ? "super" : "extends") + " " + type.toString();
}
}
......
......@@ -23,9 +23,9 @@ public class SignatureParser {
public SignatureParser(String signature) {
sign = signature;
end = sign.length();
pos = -1;
mark = 0;
end = sign.length();
}
@SuppressWarnings("unchecked")
......
......@@ -71,6 +71,7 @@ public abstract class InternalJadxTest {
assertFalse(cls.getAttributes().contains(AttributeFlag.INCONSISTENT_CODE));
return cls;
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
return null;
}
......
package jadx.tests.internal.generics;
import jadx.api.InternalJadxTest;
import jadx.core.dex.nodes.ClassNode;
import java.util.List;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
public class TestGenerics3 extends InternalJadxTest {
public static class TestCls {
public static void mthExtendsArray(List<? extends byte[]> list) {
}
public static void mthSuperArray(List<? super int[]> list) {
}
public static void mthSuperInteger(List<? super Integer> list) {
}
public static void mthExtendsString(List<? super String> list) {
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
System.out.println(code);
assertThat(code, containsString("mthExtendsArray(List<? extends byte[]> list)"));
assertThat(code, containsString("mthSuperArray(List<? super int[]> list)"));
assertThat(code, containsString("mthSuperInteger(List<? super Integer> list)"));
assertThat(code, containsString("mthExtendsString(List<? super String> list)"));
}
}
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