Brian Zhou | 16 Oct 07:12 2007
Picon

jython 2.2.1 running on phoneme-advanced (J2ME CVM)

Hi all,

I've just tested jython 2.2.1 release on both an arm little endian
linux and an arm big endian linux box with J2ME Sun's CVM.

jython-2.2.1$ cvm -cp jython.jar org.python.util.jython
Jython 2.2.1 on javaphoneme_advanced_mr2-b34
Type "copyright", "credits" or "license" for more information.
*sys-package-mgr*: processing new jar,
'/home/bzhou/test/java/jython-2.2.1/jython.jar'
*sys-package-mgr*: processing new jar,
'/opt/lib/java/phoneme-advanced/lib/foundation.jar'
>>> import java
>>> props = java.lang.System.getProperties()
>>> props
{java.library.builtin.net=yes,
sun.boot.library.path=/opt/lib/java/phoneme-advanced/lib,
java.vm.version=phoneme_advanced_mr2-b34, java.vm.vendor=Sun
Microsystems Inc., java.vendor.url=http://java.sun.com/,
path.separator=:, java.vm.name=CVM, file.encoding.pkg=sun.io,
java.vm.specification.name=Java Virtual Machine Specification,
user.dir=/share/home/bzhou/test/java/jython-2.2.1, os.arch=armv5tejl,
microedition.encoding=ISO-8859-1, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc.,
microedition.profiles=, java.awt.fonts=, os.name=Linux,
java.library.builtin.zip=yes,
java.library.path=/opt/lib/java/phoneme-advanced/lib,
microedition.platform=j2me, java.specification.name=Foundation Profile
Specification, java.class.version=47.0, sun.misc.product=phoneME
Advanced, os.version=2.6.12.6-arm1, user.home=/home/bzhou,
user.timezone=, file.encoding=ISO8859_1,
java.specification.version=1.1, java.class.path=jython.jar,
user.name=bzhou, java.vm.specification.version=1.0,
java.home=/opt/lib/java/phoneme-advanced, user.language=en,
java.specification.vendor=Sun Microsystems Inc., java.vm.info=mixed
mode, java.version=phoneme_advanced_mr2-b34, java.ext.dirs=,
sun.boot.class.path=/opt/lib/java/phoneme-advanced/lib/foundation.jar,
java.library.builtin.math=yes, microedition.commports=/dev/ttyS0,
java.vendor=Sun Microsystems Inc., file.separator=/,
microedition.configuration=CLDC-1.1,
sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little,
user.region=US, sun.cpu.isalist=}
>>>

It runs! Good job, the Jython team!

$ cvm -cp jython.jar org.python.util.jython Lib/test/pystone.py
Pystone(1.1) time for 10000 passes = 20.986
This machine benchmarks at 476.508 pystones/second

The only change I need to make is:
Index: src/org/python/core/PyString.java
===================================================================
--- src/org/python/core/PyString.java   (revision 3607)
+++ src/org/python/core/PyString.java   (working copy)
 <at>  <at>  -2027,10 +2027,7  <at>  <at> 
      *         the low-order bits of its corresponding char.
      */
     public static byte[] to_bytes(String s) {
-        int len = s.length();
-        byte[] b = new byte[len];
-        s.getBytes(0, len, b, 0);
-        return b;
+        return s.getBytes();
     }

     /**

This is needed because CVM does not have the deprecated getBytes(int
srcBegin, int srcEnd, byte[] dst, int dstBegin) method.

It is really low hanging fruit for Jython, IMO this change alone is
worth a 2.2.2 release.. With some more testing, this potentially can
get jython to all devices that runs CVM. The test devices I'm using,
for instance, are consumer NAS devices like MSS II (Maxtor Shared
Storage II) [1], Buffalo Linkstation Pro, and Linksys NSLU2, with
optware [2] cross compiled ipkg of phoneme-advanced [3]. I know
phoneme-advanced CVM also runs on mipsel and powerpc linux routers,
phones. I can package jython as ipk for all available optware feeds
[4].

Cheers,

-Brian Zhou
bzhou <at> nslu2-linux.org

URLs:
[1] http://www.nslu2-linux.org/wiki/MSSII/HomePage
[2] http://www.nslu2-linux.org/wiki/Optware/HomePage
[3] http://www.nslu2-linux.org/wiki/HowTo/UseJavaOnTheSlug
[4] http://ipkg.nslu2-linux.org/feeds/optware/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

Gmane