mirror of https://github.com/kivy/pyjnius.git
Merge pull request #409 from kivy/fix/method_order_inheritance
Fix method order inheritance
This commit is contained in:
commit
6553ad4409
|
@ -44,7 +44,7 @@ class Class(with_metaclass(MetaJavaClass, JavaClass)):
|
|||
getResource = JavaMethod('(Ljava/lang/String;)Ljava/net/URL;')
|
||||
getResourceAsStream = JavaMethod('(Ljava/lang/String;)Ljava/io/InputStream;')
|
||||
getSigners = JavaMethod('()[Ljava/lang/Object;')
|
||||
getSuperclass = JavaMethod('()Ljava/lang/reflect/Class;')
|
||||
getSuperclass = JavaMethod('()Ljava/lang/Class;')
|
||||
isArray = JavaMethod('()Z')
|
||||
isAssignableFrom = JavaMethod('(Ljava/lang/reflect/Class;)Z')
|
||||
isInstance = JavaMethod('(Ljava/lang/Object;)Z')
|
||||
|
@ -168,8 +168,11 @@ def autoclass(clsname):
|
|||
constructors.append((sig, constructor.isVarArgs()))
|
||||
classDict['__javaconstructor__'] = constructors
|
||||
|
||||
methods = c.getMethods()
|
||||
parent_class = c
|
||||
while parent_class is not None:
|
||||
methods = parent_class.getDeclaredMethods()
|
||||
methods_name = [x.getName() for x in methods]
|
||||
|
||||
for index, method in enumerate(methods):
|
||||
name = methods_name[index]
|
||||
if name in classDict:
|
||||
|
@ -219,6 +222,8 @@ def autoclass(clsname):
|
|||
|
||||
classDict[name] = JavaMultipleMethod(signatures)
|
||||
|
||||
parent_class = parent_class.getSuperclass()
|
||||
|
||||
def _getitem(self, index):
|
||||
try:
|
||||
return self.get(index)
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package org.jnius;
|
||||
|
||||
import org.jnius.Parent;
|
||||
|
||||
public class Child extends Parent {
|
||||
static public Child newInstance(){
|
||||
return new Child();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.jnius;
|
||||
|
||||
public class Parent {
|
||||
static public Parent newInstance(){
|
||||
return new Parent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
from jnius import autoclass
|
||||
|
||||
def test_newinstance():
|
||||
Parent = autoclass('org.jnius.Parent')
|
||||
Child = autoclass('org.jnius.Child')
|
||||
|
||||
child = Child.newInstance()
|
||||
|
||||
assert isinstance(child, Child)
|
||||
assert isinstance(child, Parent)
|
Loading…
Reference in New Issue