improving Py.java2py

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

improving Py.java2py

Anand Chitipothu


I have some proposal for improving jython coercion.

In the current version, coercion is not extensible. Since one of the  
main advantages of jython is to make java applications scriptable. So  
it will very helpful to have control on coercion.

The Py.java2py method is what called to coerce java objects to jython  
objects, which has comment saying it needs to rewritten.

     // Needs rewriting for efficiency and extensibility
     public static PyObject java2py(Object o) {

Support we provide a CoercionManager interface.

public interface CoercionManager {
      * Converts the given jave object to a python object.
      * Returns Py.NoConversion if coercion is not supported.
     PyObject java2py(Object jobject);

      * Converts the given jython objects to a java object.
      * Returns Py.NoConversion if coercion is not supported.
     Object py2java(PyObject object, Class clazz);

The Py.java2py method can be modified to use the coercionManager if  
present and if returns NoConversion, then the default coercion rules  
are used.

same thing can be done for Py.tojava method.

- Anand

SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play:
Jython-dev mailing list
[hidden email]