You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran across a confusing JavaException when trying to call a Java method stored in a class variable:
fromjniusimportautoclassSystem=autoclass('java.lang.System')
# This works: System.out.println('Hello World')
map(System.out.println, ['Hello World'])
println=System.out.printlnmap(println, ['Hello World'])
classMyClass(object):
def__init__(self):
self.println=System.out.println# Instance variables are fine map(MyClass().println, ['Hello World'])
# This causes an exception: classMyClass(object):
println=System.out.println# But class variables cause errors map(MyClass.println, ['Hello World'])
Running this code produces the following output:
Hello World
Hello World
Hello World
Hello World
Traceback (most recent call last):
File "jniustest.py", line 19, in <module>
map(MyClass.println, ['Hello World'])
File "jnius_export_class.pxi", line 745, in jnius.JavaMultipleMethod.__call__ (jnius/jnius.c:15502)
jnius.JavaException: No methods matching your arguments
This is an odd edge-case with an easy workaround (don't store Java methods in class variables), but I thought I'd report it here in case anyone else encounters it.
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1362787-javaexception-when-calling-java-methods-stored-in-python-class-variables?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github).
The text was updated successfully, but these errors were encountered:
dessant
changed the title
JavaException when calling Java methods stored in Python class variables
JavaException when calling Java methods stored in Python class variables
Jan 15, 2015
I ran across a confusing
JavaException
when trying to call a Java method stored in a class variable:Running this code produces the following output:
This is an odd edge-case with an easy workaround (don't store Java methods in class variables), but I thought I'd report it here in case anyone else encounters it.
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/1362787-javaexception-when-calling-java-methods-stored-in-python-class-variables?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F77133&utm_medium=issues&utm_source=github).The text was updated successfully, but these errors were encountered: