Skip to content

Commit

Permalink
fix: don't add @OverRide if super method is private (#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Sep 17, 2020
1 parent 91ee756 commit cfaa6ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ private List<IMethodDetails> collectOverrideMethods(RootNode root, List<ArgType>
ClassNode classNode = root.resolveClass(superType);
if (classNode != null) {
for (MethodNode mth : classNode.getMethods()) {
String mthShortId = mth.getMethodInfo().getShortId();
if (mthShortId.startsWith(signature)) {
overrideList.add(mth);
if (!mth.getAccessFlags().isPrivate()) {
String mthShortId = mth.getMethodInfo().getShortId();
if (mthShortId.startsWith(signature)) {
overrideList.add(mth);
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package jadx.tests.integration.others;

import org.junit.jupiter.api.Test;

import jadx.tests.api.IntegrationTest;

import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;

public class TestOverridePrivateMethod extends IntegrationTest {

public static class TestCls {
public static class BaseClass {
private void a() {
}
}

public static class MyClass extends BaseClass {
public void a() {
}
}
}

@Test
public void test() {
assertThat(getClassNode(TestCls.class))
.code()
.doesNotContain("@Override");
}
}

0 comments on commit cfaa6ab

Please sign in to comment.