Hi Steinar,
On Mon, 30 Apr 2001, Steinar Rune Eriksen wrote:
> Hi
>
> Can anyone please give me some guidance on this. I try to create a system where I use Java classes that are subclassed for prototyping in Jython. Within the rest of the Java code (after initialization) I would like to refer to standard Java classes rather than PyObject. Hence, I try to subclass a Java class in Python and later just use the Java class itself when calling methods.
>
> Am I trying to do something that is not possible within the Jython framework, or is there away around it.
>
> Java :
> class MyClass
> {
> void Method()
>
> }
>
> Jython :
>
> def PyMyClass (MyClass):
> def Method()
>
>
> Java (Factory class)
> class MyClassFactory
>
> public MyClass createMyClass()
> {
> /*
> use PythonInterpreter to create
> PyObject instance of PyMyClass()
>
> This works fine. I can call methods here (with invoke)
> */
> MyClass p=(MyClass) myPyObject;
> // Why does this typecase fail (error on PyInstance) ?
> // I thought this cast would work since the PyMyClass object subclasses MyClass... ??
>
> }
Try:
MyClass p = PyObject.__tojava__(MyClass.class);
-rb
|