From: Thomas H. <tho...@io...> - 2001-01-11 15:10:58
|
I'm just trying to get up to speed with Jython: Very impressive! One problem though: I have a java JNI component which allows to set the color of the Console (I'm using win2000 here). This works fine from any java console program, but from jython (or even from the program compiled with jythonc) I get a traceback: C:\work\chip\debugger>jython Jython 2.0beta1 on java1.3.0 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> from ColoredConsole import setColor >>> setColor(10) Traceback (innermost last): File "<console>", line 1, in ? java.lang.IllegalAccessException at java.lang.reflect.Method.invoke(Native Method) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:158) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:166) at org.python.core.PyObject.__call__(PyObject.java:272) at org.python.pycode._pyx2.f$0(<console>) at org.python.pycode._pyx2.call_function(<console>) at org.python.core.PyTableCode.call(PyTableCode.java:155) at org.python.core.Py.runCode(Py.java:1050) at org.python.core.Py.exec(Py.java:1064) at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:124) at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:87) at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:68) at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:42) at org.python.util.InteractiveConsole.push(InteractiveConsole.java:83) at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:62) at org.python.util.jython.main(jython.java:178) java.lang.IllegalAccessException: java.lang.IllegalAccessException >>> ^Z C:\work\chip\debugger> Is it possible to use native methods together with jython? Regards, Thomas |
From: <bc...@wo...> - 2001-01-12 09:25:11
|
[Thomas Heller] >I'm just trying to get up to speed with Jython: Very impressive! > >One problem though: > >I have a java JNI component which allows to set the color >of the Console (I'm using win2000 here). >This works fine from any java console program, >but from jython (or even from the program compiled with >jythonc) I get a traceback: > >C:\work\chip\debugger>jython >Jython 2.0beta1 on java1.3.0 (JIT: null) >Type "copyright", "credits" or "license" for more information. >>>> from ColoredConsole import setColor >>>> setColor(10) >Traceback (innermost last): > File "<console>", line 1, in ? >java.lang.IllegalAccessException >... > >Is it possible to use native methods together with jython? Generally yes. I have done so extensively in my JNI based "os" module implementation. One advice which I remember, is to put your java class into a package. [Quoting JimH from 25 Nov 1998:] """ > Does JNI work with jpython? I've been fiddling with it but haven't > gotten it to work. I'm guessing that the entire problem here is related to using the top-level unnamed package. I've gone into some of the issues with this before, so I won't reiterate them here. The summary is that whenever anything goes wrong with a top-level package, my first suggestion is to move it into a real named package. """ Unfortunately I can't find the post where Jim goes over the issues. regards, finn |
From: Thomas H. <tho...@io...> - 2001-01-12 12:17:31
|
I wrote: > >C:\work\chip\debugger>jython > >Jython 2.0beta1 on java1.3.0 (JIT: null) > >Type "copyright", "credits" or "license" for more information. > >>>> from ColoredConsole import setColor > >>>> setColor(10) > >Traceback (innermost last): > > File "<console>", line 1, in ? > >java.lang.IllegalAccessException > >... > > > >Is it possible to use native methods together with jython? > and Finn replied: > Generally yes. I have done so extensively in my JNI based "os" module > implementation. One advice which I remember, is to put your java class > into a package. > > [Quoting JimH from 25 Nov 1998:] > """ > > Does JNI work with jpython? I've been fiddling with it but haven't > > gotten it to work. > I'm guessing that the entire problem here is related to using the > top-level unnamed package. I've gone into some of the issues with this > before, so I won't reiterate them here. The summary is that whenever > anything goes wrong with a top-level package, my first suggestion is to > move it into a real named package. > """ > My problem is solved with the help of Jeff Emanuel who sent me the right answer: My class containing the native method(s) was not declared public. It works fine now. Thanks, Thomas |