change to getMethods and getFields to get inherited methods/fields too

and small doc fix
This commit is contained in:
gabriel.pettier 2012-08-18 19:32:15 +02:00
parent 2eea0f45d3
commit 9ec504dfd6
3 changed files with 6 additions and 4 deletions

View File

@ -9,7 +9,7 @@ Quick overview
-------------- --------------
```python ```python
>>> from jnius import autoclass >>> from jnius.reflect import autoclass
>>> autoclass('java.lang.System').out.println('Hello world') >>> autoclass('java.lang.System').out.println('Hello world')
Hello world Hello world

View File

@ -623,7 +623,7 @@ cdef class JavaMethod(object):
<char *>self.definition) <char *>self.definition)
if self.j_method == NULL: if self.j_method == NULL:
raise JavaException('Unable to found the method' raise JavaException('Unable to find the method'
' {0}({1})'.format(self.name, self.definition)) ' {0}({1})'.format(self.name, self.definition))
cdef void set_resolve_info(self, JNIEnv *j_env, jclass j_cls, cdef void set_resolve_info(self, JNIEnv *j_env, jclass j_cls,

View File

@ -9,6 +9,8 @@ class Class(JavaClass):
forName = JavaStaticMethod('(Ljava/lang/String;)Ljava/lang/Class;') forName = JavaStaticMethod('(Ljava/lang/String;)Ljava/lang/Class;')
getConstructors = JavaMethod('()[Ljava/lang/reflect/Constructor;') getConstructors = JavaMethod('()[Ljava/lang/reflect/Constructor;')
getMethods = JavaMethod('()[Ljava/lang/reflect/Method;')
getFields = JavaMethod('()[Ljava/lang/reflect/Field;')
getDeclaredMethods = JavaMethod('()[Ljava/lang/reflect/Method;') getDeclaredMethods = JavaMethod('()[Ljava/lang/reflect/Method;')
getDeclaredFields = JavaMethod('()[Ljava/lang/reflect/Field;') getDeclaredFields = JavaMethod('()[Ljava/lang/reflect/Field;')
getName = JavaMethod('()Ljava/lang/String;') getName = JavaMethod('()Ljava/lang/String;')
@ -112,7 +114,7 @@ def autoclass(clsname):
constructors.append(sig) constructors.append(sig)
classDict['__javaconstructor__'] = constructors classDict['__javaconstructor__'] = constructors
methods = c.getDeclaredMethods() methods = c.getMethods()
methods_name = [x.getName() for x in methods] methods_name = [x.getName() for x in methods]
for index, method in enumerate(methods): for index, method in enumerate(methods):
name = methods_name[index] name = methods_name[index]
@ -159,7 +161,7 @@ def autoclass(clsname):
classDict[name] = JavaMethodMultiple(signatures) classDict[name] = JavaMethodMultiple(signatures)
for field in c.getDeclaredFields(): for field in c.getFields():
static = Modifier.isStatic(field.getModifiers()) static = Modifier.isStatic(field.getModifiers())
sig = get_signature(field.getType()) sig = get_signature(field.getType())
cls = JavaStaticField if static else JavaField cls = JavaStaticField if static else JavaField