Skip to content

Commit c9c48a5

Browse files
committed
[ji] avoid "multiple Java methods found" warning
1 parent e0de6e1 commit c9c48a5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/main/java/org/jruby/javasupport/binding/MethodGatherer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ private static boolean sameTypesAndAccessModifier(Method child, Method parent) {
215215
}
216216

217217
private static boolean methodsAreEquivalent(Method child, Method parent) {
218+
if (child.getDeclaringClass().isAssignableFrom(parent.getDeclaringClass()) && child.getDeclaringClass() != parent.getDeclaringClass()) {
219+
final Method temp = parent; // swap them since child is actually the parent in terms of class hierarchy
220+
parent = child; child = temp;
221+
}
222+
218223
if (parent.getDeclaringClass().isAssignableFrom(child.getDeclaringClass())) {
219224
return sameTypesAndAccessModifier(child, parent); // most cases will end here
220225
}
@@ -261,7 +266,7 @@ private static void addNewMethods(
261266
// we have seen other methods; check if we already have an equivalent one
262267
for (int i = 0; i < childMethods.size(); i++) {
263268
final Method current = childMethods.get(i);
264-
if ( methodsAreEquivalent(current, method) ) {
269+
if (methodsAreEquivalent(current, method)) {
265270
if (removeDuplicate) {
266271
// Replace the existing method, since the super call is more general
267272
// and virtual dispatch will call the subclass impl anyway.

0 commit comments

Comments
 (0)