Jan Wedel | 18 Mar 12:44
Picon

Change compiler compliance level for byte codes or recompile with lower compliance level?

Hi,

 

I have managed to run a python generated midlet in a JavaME emulator. The problem is, that the emulator returns with:

 

Installing suite from: http://127.0.0.1:1215/midlettest.jad

java.lang.Error: ClassFormatError:  56

 - java.lang.Class.forName(), bci=0

 - com.sun.midp.main.CldcMIDletLoader.newInstance(), bci=1

 - com.sun.midp.midlet.MIDletStateHandler.createMIDlet(), bci=66

 - com.sun.midp.midlet.MIDletStateHandler.createAndRegisterMIDlet(), bci=17

 - com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=27

 - com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52

 - com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8

 - com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161

 - com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

 

I read somewhere that this error is related to incompatible bytecodes or class file format. JavaME supports Java 1.3 (AFAIK) and Jython obviously uses the latest (1.5).

 

So, is there a way to specify to compiler compliance level when generating the class files or is it possible to generate a Java file instead of a class file so I can manually change and recompile it?

 

Thanks,

 

Jan

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Alex Grönholm | 17 Mar 22:33
Picon

Re: Inheriting from a Java class with no default constructor

17.3.2010 21:41, Jeff Emanuel kirjoitti:
> By passing self as the second argument to
> PropertyChangeSupport.__init__, you are trying
> to pass an unconstructed object.  You need a
> different Object for the second argument.  You
> can't do that in Java either.  The following
> equivalent Java code fails to compile with this
> error:
>
>
> cannot reference this before supertype constructor has been called
>     super(this);
>           ^
>
> import java.beans.PropertyChangeSupport;
> public class PCS extends PropertyChangeSupport {
>   public PCS() { super(this); }
> }
Yup, you are right. I guess I've been out of touch from Java for too 
long not to see this.
Inheriting from PropertyChangeSupport would have been a nice shortcut to 
providing bound properties support that Java code could also access.
>
>
>
> Alex Grönholm wrote:
>> How can I inherit from a Java class that doesn't have a default
>> constructor? If I try this:
>>
>> from java.beans import PropertyChangeSupport
>>
>> class A(PropertyChangeSupport):
>>      def __init__(self):
>>          PropertyChangeSupport.__init__(self, self)
>>
>> A()
>>
>> I get: TypeError: Default constructor failed for Java superclass
>> java.beans.PropertyChangeSupport
>>
>> Is this impossible, or am I doing something wrong? Or is there a bug
>> in Jython?
>> This was tested on SVN trunk.
>>
>>
>> ------------------------------------------------------------------------------
>>
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Jython-users mailing list
>> Jython-users <at> lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jython-users

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Jan Wedel | 17 Mar 17:59
Picon

How to create self-contained jar including App & Jython class files?

Hi,

The general question is: How can I create a self-contained jar file with 
the jython application and jython libs?

Here is some background:

After a LOT of work and the very appreciated help of Charlie Groves I 
managed to create a class file from a python script that uses static 
proxies (from the customizable-proxies branch). This class file 
implements a j2me midlet interface and will be loaded by the KVM or a 
WTK emulator. The application HAS to be in a self-contained jar 
including ALL necessary classes because dynamic ClassLoading is not 
supported.

The problem is, that if I run the created midlet within the emulator, I 
get the following error (the bit of german says "No valid Win32 
application":

java.io.IOException: Cannot run program 
"C:\Programme\Java\jre6\bin\java": Creat
eProcess error=193, %1 ist keine zulõssige Win32-Anwendung
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at com.sun.kvem.environment.JVM.run(Unknown Source)
        at 
com.sun.kvem.environment.EmulatorInvoker.runEmulatorOtherVM(Unknown S
ource)
        at com.sun.kvem.environment.EmulatorInvoker.runEmulator(Unknown 
Source)
        at 
com.sun.kvem.environment.ProfileEnvironment$KVMThread.runEmulator(Unk
nown Source)
        at 
com.sun.kvem.environment.ProfileEnvironment$KVMThread.run(Unknown Sou
rce)
Caused by: java.io.IOException: CreateProcess error=193, %1 ist keine 
zulõssige
Win32-Anwendung
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 8 more

This has to be related to jython because I get a similar error when I 
run the normal (not the configurable-proxies branch) Jython.bat which is 
in the windows PATH an then type "exit()":

C:\>jython.bat
Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_17
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
java.io.IOException: Cannot run program 
"C:\Programme\Java\jre6/bin/java": Creat
eProcess error=193, %1 ist keine zulõssige Win32-Anwendung
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at com.sun.jna.Native$DeleteNativeLibrary.run(Native.java:761)
Caused by: java.io.IOException: CreateProcess error=193, %1 ist keine 
zulõssige
Win32-Anwendung
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 4 more

I would be REALLY helpful if someone knows this error or has an idea hot 
to solve it!

Thanks a lot,

Jan

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Peter Lauri | 17 Mar 17:11

Java system, want to use Python for some tasks?

Hi,

Is Jython the right thing for us? We have a java system, but for some tasks (user defined) we want to be able to give some flexibility to the users to be able to customize their usage of the application. We want a scripting language for this to make it easier for the end user.

Is Jython a way to go?

/Peter
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Alex Grönholm | 17 Mar 06:02
Picon

Inheriting from a Java class with no default constructor

How can I inherit from a Java class that doesn't have a default 
constructor? If I try this:

from java.beans import PropertyChangeSupport

class A(PropertyChangeSupport):
     def __init__(self):
         PropertyChangeSupport.__init__(self, self)

A()

I get: TypeError: Default constructor failed for Java superclass 
java.beans.PropertyChangeSupport

Is this impossible, or am I doing something wrong? Or is there a bug in 
Jython?
This was tested on SVN trunk.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Kai Hackemesser | 15 Mar 22:30
Picon

Re: calling embedded jython from other java class


Why are you trying to run Robot Framework directly from Java in your
Maven plugin? Couldn't you simply run it through the system and then
be able to use both Python and Jython interpreters? I think that was
the idea in the prototype version that was created some time ago [1].
Anyway, this discussion is probably better continued on
robotframework-users mailing list.


Lets say a memory issue. Having the Hudson VM starting the Maven VM starting the Jython VM makes just too many VMs for our testing box. It works of course, but take more time than a direct call. all these VMs have a minimum memory consumption of 1GB per VM. And if I would have the option to call it internally, I would do it.

BTW I have processed this further and I solved the issue for random.py - it was just not aware of the /Lib folder in the jython jar, so I added it to the classpath. But then later it failed for something in ntpaths.py or so and I gave up for now, had to be a bit productive.

Cheers,
SF
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Tom Nichols | 15 Mar 20:49
Picon
Gravatar

Loading standard python modules from the classpath

So in working on my python web console, I've only just realized that
all of the standard CPython modules that Jython supports actually
exist as .py files that are loaded at runtime.  This presents a
potentially serious problem for me:  AppEngine doesn't allow direct
file access at runtime!  I suspect the internals of Jython's import
mechanism is looking for a .py file on the system path, which won't
work at all in the Java AppEngine runtime.  Now, if there's a way for
those imports to be read from the classpath instead of the filesystem,
then I'll be all set.  If not, the project is somewhat hosed, as the
inability to use virutally _any_ of the standard cpython libraries
presents a considerable limitation to the project.

Can Jython modules be loaded from the classpath??

Any suggestions from the wise Jython project maintainers?

Thanks.
-Tom

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
john.m.baker | 15 Mar 13:36
Favicon

Mixing Java and Jython

Hello,

Im wondering how far I can mix Java and Jython.  Ive got some Jython that I run from a PythonInterpreter, and Id like the Jython to run some Java.  Can I pass a reference to a Java object to the Jython, i.e.:

         PythonInterpreter pi = new PythonInterpreter(); 

         pi.exec("import jython.database");

         PyObject p = pi.eval("jython.database.createDomain("+hostDAO+", '"+domain+"')");

Where hostDAO is a reference to a Java object, which if youre interested, interacts with Hibernate.

Thanks for your feedback.

John



This e-mail (including any attachments) is confidential, may contain
proprietary or privileged information and is intended for the named
recipient(s) only. Unintended recipients are prohibited from taking action
on the basis of information in this e-mail and must delete all copies.
Nomura will not accept responsibility or liability for the accuracy or
completeness of, or the presence of any virus or disabling code in, this
e-mail. If verification is sought please request a hard copy. Any reference
to the terms of executed transactions should be treated as preliminary only
and subject to formal written confirmation by Nomura. Nomura reserves the
right to monitor e-mail communications through its networks (in accordance
with applicable laws). No confidentiality or privilege is waived or lost by
Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
a reference to any entity in the Nomura Holdings, Inc. group. Please read
our Electronic Communications Legal Notice which forms part of this e-mail:
http://www.Nomura.com/email_disclaimer.htm
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users
Pekka Klärck | 15 Mar 09:09
Picon
Picon
Favicon

Re: calling embedded jython from other java class

[Resending because I first used wrong sending address and the email
was blocked.]

2010/3/7 Kai Hackemesser <kai.hackemesser <at> gmail.com>:
> I debugged a bit in the meantime on this issue.
>
> For reference see the source code at
> http://code.google.com/p/robotframework/source/browse/#svn/trunk/src/robot
>
> that 'robot' module has a module 'common' which has the file model.py:
>
> http://code.google.com/p/robotframework/source/browse/trunk/src/robot/common/model.py
>
> this has an import statement at line 16:
>
> import random
>
> The classloader is then asked to to resolve
> "robot/common/random/__init__$py.class", followed by
> "robot/common/random/__init__.py", "robot/common/random$py.class" and
> "robot/common/random.py"
>
> The URL class loader is not asked for "Lib/random.py" or it's $py.class
> file. which would match with the one in the jython standalone file (I have
> tested finding it with this string). Is this a bug in the Jython resolver or
> should I tell the people from the robotframework to use a different way to
> import it? (If the is one - my python knowledge is not much better than my
> knowledge of the Human Genome Project - I know it exists and what they try
> to do.)

I don't think there's anything wrong with `import random`, it should
simple import the standard random module. This seems to be either a
problem in your setup or a Jython bug.

Why are you trying to run Robot Framework directly from Java in your
Maven plugin? Couldn't you simply run it through the system and then
be able to use both Python and Jython interpreters? I think that was
the idea in the prototype version that was created some time ago [1].
Anyway, this discussion is probably better continued on
robotframework-users mailing list.

[1] http://code.google.com/p/robotframework-javatools/source/browse/#svn/maven-plugin

Cheers,
   .peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Tom Nichols | 12 Mar 20:05
Picon
Gravatar

Ann: Python Web Console!

Hello again, Jython community,

I'd first like to point out an early version of the Python web console:
http://pythonwebconsole.appspot.com/
Powered by Jython!  This is similar to TryPython, except more in the
spirit of the Groovy Web Console where scripts can be published and
shared.

I know, the irony level is pretty high here, but I thought it could be
a good showcase for Jython.  However, I'm not entirely comfortable
with the level of sandboxing done for scripts currently.  If I _want_
my scripts to run in a totally isolated environment, with an isolated
classloader (so that generated classes can be thrown away,) how would
I do that?  As I mentioned before, I'm not clear on how to set a
classloader per PythonInterpreter instance, and it appears that a
static classloader is used.  Will defined classes eventually pile up
over time and never be GC'd?

If anyone can point to documentation or give advice on how to properly
isolate and sandbox scripts, that would be great.  In addition, please
feel free to play with the console, tell your friends, and report any
bugs and suggestions for improvement back to me.

The full source can be downloaded from github as well:
http://github.com/tomstrummer/

Thanks!
-Tom

2010/3/4 Tom Nichols <tmnichols <at> gmail.com>:
> Hi Jython community,
>
> I'm trying to determine how one would sandbox an untrusted Jython
> script evaluated with PythonInterpreter.
>
> So far I've figured out that I can create a new PythonInterpreter with
> a new PySystemState every time, which will discard locals after every
> script execution.  However I've noticed that PySystemState uses a lot
> of static fields to keep track of various things.  Is it possible for
> an evaluated python script to affect some static portions of
> PySystemState?
>
> A secondary question is how to restrict scripts from accessing classes
> that are part of the application.  I don't want scripts to modify my
> data model or reconfigure the web server.  It looks like PySystemState
> takes two classloaders in its static initialize routine -- are one of
> them used to load classes that are referenced from evaluated scripts?
>
> Some context -- I'm attempting to write an online python script
> interpreter, similar to TryPython, TryRuby, and the Groovy Web
> Console.  Actually I want this to be more like the Groovy Web Console
> where users can publish and share scripts.  I teach an intro to Python
> class and I want my students to share scripts that they've created.
> The app itself will run on Google AppEngine (ironically not the Python
> runtime, since that is apparently more difficult to sandbox).  Since
> Jython is meant to be embedded, I'm hoping someone has figured out how
> to sandbox it properly.
>
> Thanks in advance for the advice.
>
> -Tom
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Josh Juneau | 12 Mar 16:56
Picon

Jython Podcast - Episode #17 Released - Interview with the authors of The Definitive Guide to Jython

I've released a special interview podcast with the five authors of The Definitive Guide to Jython.  You can go to the website http://www.jythonpodcast.com or iTunes to listen.


Thanks to all of the authors for setting the time aside for the interview, we had a great discussion.

Have a good weekend, and enjoy the podcast!
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jython-users mailing list
Jython-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users

Gmane