core: allow method name be same as class name (issue #15)
This commit is contained in:
@@ -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();"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user