core: allow method name be same as class name (issue #15)

This commit is contained in:
Skylot
2014-08-18 20:45:36 +04:00
parent fb9ff7748a
commit ee56610f06
2 changed files with 39 additions and 6 deletions
@@ -339,12 +339,7 @@ public class MethodNode extends LineAttrNode implements ILoadable {
}
public String getName() {
String name = mthInfo.getName();
if (name.equals(parentClass.getShortName())) {
return name + "_";
} else {
return name;
}
return mthInfo.getName();
}
public ClassNode getParentClass() {
@@ -0,0 +1,38 @@
package jadx.tests.internal.names;
import jadx.api.InternalJadxTest;
import jadx.core.dex.nodes.ClassNode;
import org.junit.Test;
import static jadx.tests.utils.JadxMatchers.containsOne;
import static org.junit.Assert.assertThat;
public class TestSameMethodsNames extends InternalJadxTest {
public static class TestCls<V> {
public static void test() {
new Bug().Bug();
}
public static class Bug {
public Bug() {
System.out.println("constructor");
}
void Bug() {
System.out.println("Bug");
}
}
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
System.out.println(code);
assertThat(code, containsOne("new Bug().Bug();"));
}
}