Thanks, been away myself… will give this a try when I get back into the office…


From: Mark Melvin []
Sent: Tuesday, September 01, 2009 8:41 AM
To: Joey Jarosz; Jython Users
Subject: RE: [Jython-users] Calling execfile() with xxx$py.class file


Hi Joey,


Sorry for the delay – I have been away.  If it isn’t too late, I have done this in the past:


from org.python.core import BytecodeLoader

code = BytecodeLoader.makeCode('xxx$py', '\xCA\xFE\xBA\xBE\x00\x03\x00…..lots of bytecode….x00\x00\t')

exec code


If you read your .class file into a raw string, that will work.  There are probably other methods that you can use.  Have a look at org.python.core.BytecodeLoader.





From: Joey Jarosz []
Sent: Friday, August 28, 2009 5:50 PM
To: Jython Users
Subject: [Jython-users] Calling execfile() with xxx$py.class file


I have Jython embedded in my application. I have some users who want to not pass the raw text of a python script around to some other users, but rather would prefer to only give them the $py.class file generated by Jython when a py file is loaded. Essentially they want an execfile() equivalent that can accept a $py.class file instead of a .py file.


The way I have things setup I have an opportunity to implement such functionality either in python or in my java code, so I was wondering the best way to go about make this happen. It seems like I just need access to the methods that load the .class file and convert them to PyCode so I can then pass that onto Py.runCode() or something – any pointers to the best way to start attacking this problem?


Sometimes these scripts are just that, simple scripts – not class or function definitions.


Joey Jarosz

Senior Architect

Chip Planning Solutions

Cadence Design Systems, Inc.
(408) 914-6269

Need some IP? Check out