Commit 550659d3 authored by Skylot's avatar Skylot

Fix generic types for abstract methods

parent ba1524dc
...@@ -70,31 +70,22 @@ public class MethodNode extends AttrNode implements ILoadable { ...@@ -70,31 +70,22 @@ public class MethodNode extends AttrNode implements ILoadable {
this.parentClass = classNode; this.parentClass = classNode;
this.accFlags = new AccessInfo(mth.getAccessFlags(), AFType.METHOD); this.accFlags = new AccessInfo(mth.getAccessFlags(), AFType.METHOD);
this.methodData = mth; this.methodData = mth;
this.noCode = (methodData.getCodeOffset() == 0);
if (methodData.getCodeOffset() == 0) {
noCode = true;
regsCount = 0;
retType = mthInfo.getReturnType();
initArguments(mthInfo.getArgumentsTypes());
} else {
noCode = false;
}
} }
@Override @Override
public void load() throws DecodeException { public void load() throws DecodeException {
if (noCode) try {
if (noCode) {
regsCount = 0;
initMethodTypes();
return; return;
}
try {
DexNode dex = parentClass.dex(); DexNode dex = parentClass.dex();
Code mthCode = dex.readCode(methodData); Code mthCode = dex.readCode(methodData);
regsCount = mthCode.getRegistersSize(); regsCount = mthCode.getRegistersSize();
initMethodTypes();
if (!parseSignature()) {
retType = mthInfo.getReturnType();
initArguments(mthInfo.getArgumentsTypes());
}
InsnDecoder decoder = new InsnDecoder(this, mthCode); InsnDecoder decoder = new InsnDecoder(this, mthCode);
InsnNode[] insnByOffset = decoder.run(); InsnNode[] insnByOffset = decoder.run();
...@@ -117,6 +108,13 @@ public class MethodNode extends AttrNode implements ILoadable { ...@@ -117,6 +108,13 @@ public class MethodNode extends AttrNode implements ILoadable {
} }
} }
private void initMethodTypes() {
if (!parseSignature()) {
retType = mthInfo.getReturnType();
initArguments(mthInfo.getArgumentsTypes());
}
}
@Override @Override
public void unload() { public void unload() {
if (noCode) if (noCode)
...@@ -185,12 +183,12 @@ public class MethodNode extends AttrNode implements ILoadable { ...@@ -185,12 +183,12 @@ public class MethodNode extends AttrNode implements ILoadable {
private void initArguments(List<ArgType> args) { private void initArguments(List<ArgType> args) {
int pos; int pos;
if (!noCode) { if (noCode) {
pos = 1;
} else {
pos = regsCount; pos = regsCount;
for (ArgType arg : args) for (ArgType arg : args)
pos -= arg.getRegCount(); pos -= arg.getRegCount();
} else {
pos = 2 * args.size() + 1;
} }
if (accFlags.isStatic()) { if (accFlags.isStatic()) {
......
...@@ -11,7 +11,11 @@ public class TestGenerics extends AbstractTest { ...@@ -11,7 +11,11 @@ public class TestGenerics extends AbstractTest {
public Class<?>[] classes; public Class<?>[] classes;
public static class GenericClass implements Comparable<String> { public interface MyComparable<T> {
public int compareTo(T o);
}
public static class GenericClass implements MyComparable<String> {
@Override @Override
public int compareTo(String o) { public int compareTo(String o) {
return 0; return 0;
......
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