Hi,
I've just discovered an annoying bug in JPype concerning the overloading of a method in both a grandparent class and its grandchildren.
An example will be more eloquent :
In Java, there are 3 classes : A, B and C
B inherits from A
C inherits from B
A contains a method calls foo() (with no argument)
C contains a method called foo(int i) (with an int)
In Python, when you instantiate a C object and call the foo method with no argument, an "No matching overloads" exception is raised.
Here's the example code :
A.java
public class A {
public void foo() {
System.out.println("foo() in A");
}
}
B.java
public class B extends A {
}
C.java
public class C extends B {
public void foo(int i) {
System.out.println("foo int in C");
}
}
Python
from jpype import *
jarpath = '...'
startJVM("/usr/lib/jvm/java-1.5.0-sun-1.5.0.18/jre/lib/i386/client/libjvm.so", "-Djava.ext.dirs=%s" % jarpath)
C = JClass('C')
c = C()
c.foo(1) # Is working
c.foo() # Raise an exception :
# File "testbug.py", line 15, in <module>
# c.foo()
#RuntimeError: No matching overloads found. at src/native/common/jp_method.cpp:121
The problem seems to come from the method JPClass::loadMethods() which only look at the overloading methods of the super class but not higher.
Julien
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Correction patch
Last edit: Anonymous 2013-11-21
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
I attached a patch which seem to correct this issue.
Last edit: Anonymous 2017-07-11
Can you please guide, how we can use this patch ?
how to patch