Clamp Development

View: New views
10 Messages — Rating Filter:   Alert me  

Clamp Development

by Jan Wedel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi,

 

I’m searching for a way to run (precompiled) python scripts on a Java VM (Embedded KVM, CLDC, IMP). I recently developed a port of the PyMite Python VM to Java ME. It worked but was way too slow. I wrote some performance tests and the Python script was 300x slower that the native Java script. Unfortunately it is not possible to develop native C application. I need to stick with Java.

 

I think Jython is a little bit the same approach like my port but mostly for desktop computer. And the Jython Compiler was discontinued. I read that Clamp continues this development. Clamp would allow to generate Java Sources which I can compile to Java ME byte code. But clamp is not very good documented. I checked out the clamp trunk which also needs the Jython Libraries. But both cannot compile. I get a lot of errors... I tried to contact the clamp developer but he didn’t respond.

 

However, my question is, do see that there is a chance to get it working to create java class files from full-featured python scripts?

 

If there is some work to do, I can offer my help on a daily base. But this depends on how much work is to do.

 

Regards,

 

Jan Wedel


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: Clamp Development

by Charlie Groves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jan,

On Tue, Oct 27, 2009 at 2:37 AM, Jan Wedel <Jan.Wedel@...> wrote:
> I think Jython is a little bit the same approach like my port but mostly for
> desktop computer. And the Jython Compiler was discontinued. I read that
> Clamp continues this development. Clamp would allow to generate Java Sources
> which I can compile to Java ME byte code. But clamp is not very good
> documented. I checked out the clamp trunk which also needs the Jython
> Libraries. But both cannot compile. I get a lot of errors... I tried to
> contact the clamp developer but he didn’t respond.

Apologies for not responding to your initial email yet; it's still
sitting in my inbox, waiting for me to get around to it.

Clamp definitely isn't ready for regular usage.  I've got one more
major change to make to jython's proxy generation to support it that's
sitting half completed in my local copy, and then at least the basic
structure will be stable.  At that point, I can document it and a few
brave early adopters like yourself can try it out.

Like your email, that's waiting for me to scrape together the time to
do something about it.  A few other people have expressed interest in
working on it, so I need to get it to a point that collaboration makes
sense.  It's mostly there, so I feel like I can get it there in a
couple weeks.  Maybe publicly setting a date like that will shame me
into making time for it.

> However, my question is, do see that there is a chance to get it working to
> create java class files from full-featured python scripts?

It lets you create all the bytecode needed to run Python on the JVM at
compile time.  It also lets you create Java classes out of Python
classes to let you call your Python code directly from Java.  I'm not
sure if that's enough for what you need.  It doesn't create Java
source like you mentioned above.

> If there is some work to do, I can offer my help on a daily base. But this
> depends on how much work is to do.

After I get it working basically, there's going to be some work going
through Jython's standard library looking for Python classes that
extend Java classes so we can statically compile them and Jython can
run in JVMs that don't allow bytecode to be injected at runtime.  I
could definitely use some help with that, along with getting some
feedback from someone actually using it when it's operational.

Charlie

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: Clamp Development

by Jan Wedel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey Charlie,

better now than never ;) Thanks for your reply!

>At that point, I can document it and a few
>brave early adopters like yourself can try it out.

Yeah, I would :)

> Maybe publicly setting a date like that will shame me
> into making time for it.

Good idea! Do it! The problem is, that I have to develop an application
for different target (Java, Python + C) platforms. At the current stage,
I can still descide because I'm still in the phase of gathering software
reqirements. Also designing ist not the problem. But once I start to
implement Java code, it's too late.

> It lets you create all the bytecode needed to run Python on the JVM at
> compile time.  It also lets you create Java classes out of Python
> classes to let you call your Python code directly from Java.  I'm not
> sure if that's enough for what you need.  It doesn't create Java
> source like you mentioned above.

No, I definitely don't need java sources. I just need something that
runs almost at native speed. That would be Python programs compiled to
java bytecode. What do you mean by "Python classes"? Do you mean pyc
file (python byte code)? I would be nice, if 3rd party libs could
compile with clamp too. That leads to the other question: What Python
language features does clamp currently support?

> After I get it working basically, there's going to be some work going
> through Jython's standard library looking for Python classes that
> extend Java classes so we can statically compile them and Jython can
> run in JVMs that don't allow bytecode to be injected at runtime.  

That's exactly what I need ;) the KVM doesn't support dynamic class
loading.

> I could definitely use some help with that, along with getting some
> feedback from someone actually using it when it's operational.

Ok, I'm in. As long as you could provide some brief documentation about
what libraries I need to compile/run clamp. I imported clamp and jython
into Netbeans (maybe I shouldn't have ;) ) but I get a lot of reference
errors.

Cheers, Jan


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: Clamp Development

by Charlie Groves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 29, 2009 at 9:04 AM, Jan Wedel <Jan.Wedel@...> wrote:

>> It lets you create all the bytecode needed to run Python on the JVM at
>> compile time.  It also lets you create Java classes out of Python
>> classes to let you call your Python code directly from Java.  I'm not
>> sure if that's enough for what you need.  It doesn't create Java
>> source like you mentioned above.
>
> No, I definitely don't need java sources. I just need something that
> runs almost at native speed. That would be Python programs compiled to
> java bytecode. What do you mean by "Python classes"? Do you mean pyc
> file (python byte code)? I would be nice, if 3rd party libs could
> compile with clamp too. That leads to the other question: What Python
> language features does clamp currently support?

By Python classes, I mean a class defined in Jython's runtime.  Clamp
is just a little layer on top of Jython that takes decorators you add
to your Python class source and uses them to define a Java class that
can call that Python class directly.  As such, it supports any Python
features that Jython supports.

If you just want to use arbitrary Python modules in Jython without
dynamic compilation and don't care about exposing them as Java
classes, clamp isn't adding anything.  However, one of the things I
added to Jython for clamp is the ability to specify where to store the
bytecode Jython generates and that stored bytecode should be used
instead of always dynamically generating it.  That should allow you to
use 3rd party libs in a restricted environment.

I'm a little worried about your desire for "native speed".  Jython is
a decently fast implementation of Python, but it's not going to be as
fast as plain Java code.  I don't have a good feel for what the ratio
is of Java performance to Jython performance these days, especially
for VMs other than Sun's, so I can't say how much slower Jython will
be.  What level of performance do you need?  Maybe someone else here
can give you an idea of how Jython will do.

>> I could definitely use some help with that, along with getting some
>> feedback from someone actually using it when it's operational.
>
> Ok, I'm in. As long as you could provide some brief documentation about
> what libraries I need to compile/run clamp. I imported clamp and jython
> into Netbeans (maybe I shouldn't have ;) ) but I get a lot of reference
> errors.

I'll provide that documentation as soon as I get my work merged back into trunk.

Charlie

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Parent Message unknown Re: Clamp Development

by Charlie Groves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Nov 2, 2009, at 3:42, "Jan Wedel" <Jan.Wedel@...> wrote:

> Hi!
>
>> If you just want to use arbitrary Python modules in Jython without
>> dynamic compilation and don't care about exposing them as Java
>> classes, clamp isn't adding anything.  However, one of the things I
>> added to Jython for clamp is the ability to specify where to store  
>> the
>> bytecode Jython generates and that stored bytecode should be used
>> instead of always dynamically generating it.  That should allow you  
>> to
>> use 3rd party libs in a restricted environment.
>
> Do you mean Java byte code or Python byte code? If Python actually
> generates Java byte code, where can I find it? Do you know any
> documentation by chance, that explains how to generate Java class  
> files
> or (in an optimal way) create a self-contained jar file from Python
> code?

It's java byte code.  Whenever you import a module with jython, it  
spits out  a $py.class file corresponding to the imported module in  
the same directory. You can use the compileall module included with  
jython to compile a whole directory tree and control where it's  
output.  After compiling everything, you no longer need the .py files.  
I think there are a couple guides on the wiki for doing this.

However jython still generates java bytecode for proxy classes at  
runtime, even if the modules containing the proxy classes are  
precompiled. This is what the proxy generation branch takes care of.

>> I'm a little worried about your desire for "native speed".  Jython is
>> a decently fast implementation of Python, but it's not going to be as
>> fast as plain Java code.  I don't have a good feel for what the ratio
>> is of Java performance to Jython performance these days, especially
>> for VMs other than Sun's, so I can't say how much slower Jython will
>> be.  What level of performance do you need?  Maybe someone else here
>> can give you an idea of how Jython will do.
>
> I've done some performance tests on my Python Interpreter. It runs
> 200-300 times slower that the same program coded in "native" Java.  
> Hmm,
> I think I'm still a bit confused about what Jython does.
>
> Is Jython "only" a Java implementation of the CPython interpreter?  
> That
> would mean, you always need the whole Jython core/interpreter libs to
> create a self contained Jar file. Or, is Jython/Clamp able to create
> "native" Java byte code without a Python Interpreter in between?
>
> Like this:
> Python source -> Jython Interpreter -> Jython interprets code and
> executes at runtime in a Java VM
> Or more like this
> Python source -> Java byte code -> Java Interpreter of the VM  
> interprets
> byte code at runtime (Jython not necessary anymore)

Jython creates bytecode that's run directly by the jvm, but much of  
the core pieces of python are implemented in java and are still needed  
by the generated bytecode.  Things like list, dict, int, str and so on  
are contained in jython's jar, so it's still needed by the compiled  
modules.  So jython isn't interpreting anything, but it still needs  
some core classes.

Charlie


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: Clamp Development

by Jan Wedel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Charlie,

I'm not sure if you're aware of that, but I just described my problem to
the jython-users group. And they told me Clamp is exactly what I'm
looking for. ;) So, first jython, than clamp, then jython, now clamp
again...I'm bit puzzled but I think I understand approximately what
Clamp is designed to do.

I followed your advise, used compile all, built a JAR file containing
the class and the whole Jython lib (I planned to stip it down when it's
working) and then passed it to the Java ME emulator. But is sais "can'T
find MIDlet class". Then I observed the Java byte code generated by
Jython and saw that the resulting class is not implementing MIDlet but
PyRunnable and an $1 has been added to the class name. I think, this
makes it impossible for the emulator to run the MIDlet.

So, I have to admit that I'm not really sure what exactly the "proxy
classes" you were talking about are doing. Alex Grönholm told me, that
you have not finished to implement all proxy generation hooks. But what
are they for? Do they act as correctly named interfaces to other native
Java classes? Something like you generate one proxy class for each
jython class that looks like a class how it should be in Java but which
delivers the calls to subjacent jython classes / methods?

If yes, then it really seems, that Clamp should solve my problem,
shouldn't it?

Whatever, I already offered you my help. So if there is anything I could
do, just say it. In your first mail, you explained that your work is
half way done but it's still on your working copy and not committed yet.
If you like, I'll be glad to have a look on the current code just to get
an idea what you are doing and how I could possibly help. You could just
send the important classes as a zip file to me. I doesn't have to work,
I doesn't need to be compilable and fully commented, it's just to get an
overview.

Thanks,

Jan

> -----Ursprüngliche Nachricht-----
> Von: Charlie Groves [mailto:charlie.groves@...]
> Gesendet: Dienstag, 3. November 2009 20:19
> An: Jan Wedel
> Cc: jython-dev@...
> Betreff: Re: AW: Re: [Jython-dev] Clamp Development
>
> On Nov 2, 2009, at 3:42, "Jan Wedel" <Jan.Wedel@...> wrote:
>
> > Hi!
> >
> >> If you just want to use arbitrary Python modules in Jython without
> >> dynamic compilation and don't care about exposing them as Java
> >> classes, clamp isn't adding anything.  However, one of the things I
> >> added to Jython for clamp is the ability to specify where to store
> >> the
> >> bytecode Jython generates and that stored bytecode should be used
> >> instead of always dynamically generating it.  That should allow you
> >> to
> >> use 3rd party libs in a restricted environment.
> >
> > Do you mean Java byte code or Python byte code? If Python actually
> > generates Java byte code, where can I find it? Do you know any
> > documentation by chance, that explains how to generate Java class
> > files
> > or (in an optimal way) create a self-contained jar file from Python
> > code?
>
> It's java byte code.  Whenever you import a module with jython, it
> spits out  a $py.class file corresponding to the imported module in
> the same directory. You can use the compileall module included with
> jython to compile a whole directory tree and control where it's
> output.  After compiling everything, you no longer need the .py files.
> I think there are a couple guides on the wiki for doing this.
>
> However jython still generates java bytecode for proxy classes at
> runtime, even if the modules containing the proxy classes are
> precompiled. This is what the proxy generation branch takes care of.
>
> >> I'm a little worried about your desire for "native speed".  Jython
> is
> >> a decently fast implementation of Python, but it's not going to be
> as
> >> fast as plain Java code.  I don't have a good feel for what the
> ratio
> >> is of Java performance to Jython performance these days, especially
> >> for VMs other than Sun's, so I can't say how much slower Jython
will
> >> be.  What level of performance do you need?  Maybe someone else
here

> >> can give you an idea of how Jython will do.
> >
> > I've done some performance tests on my Python Interpreter. It runs
> > 200-300 times slower that the same program coded in "native" Java.
> > Hmm,
> > I think I'm still a bit confused about what Jython does.
> >
> > Is Jython "only" a Java implementation of the CPython interpreter?
> > That
> > would mean, you always need the whole Jython core/interpreter libs
to

> > create a self contained Jar file. Or, is Jython/Clamp able to create
> > "native" Java byte code without a Python Interpreter in between?
> >
> > Like this:
> > Python source -> Jython Interpreter -> Jython interprets code and
> > executes at runtime in a Java VM
> > Or more like this
> > Python source -> Java byte code -> Java Interpreter of the VM
> > interprets
> > byte code at runtime (Jython not necessary anymore)
>
> Jython creates bytecode that's run directly by the jvm, but much of
> the core pieces of python are implemented in java and are still needed
> by the generated bytecode.  Things like list, dict, int, str and so on
> are contained in jython's jar, so it's still needed by the compiled
> modules.  So jython isn't interpreting anything, but it still needs
> some core classes.
>
> Charlie
>



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: Clamp Development

by Jan Wedel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey Charlie,

I guess you're busy right now, but I just want to clarify some things.
To make a Jython class file run on a JavaME, they need to be compatible
with CLDC and MIDP/IMP. That means the ClassLoader and e.g. JNI is not
supported. Moreover, the APIs are very limited (see
http://java.sun.com/javame/reference/apis/jsr118/). E.g., HashMap and
Templates are not supported. Instead, Hashtable and type casting must be
used. That means, there might be some work to do to make it compatible
with JavaME. Can you approximate if there is a lot of code needs to be
ported? Or even some parts that heavily depend on dynamic class loading
(with can not be implemented in JaveME CLDC at all)? This is only
important for all Jython/Clamp classes that are needed at runtime on the
embedded environment and not interpreter or interactive promt stuff.

Maybe you or a Jython dev could comment on that.

Thanks,

jan

> -----Ursprüngliche Nachricht-----
> Von: Charlie Groves [mailto:charlie.groves@...]
> Gesendet: Dienstag, 3. November 2009 20:19
> An: Jan Wedel
> Cc: jython-dev@...
> Betreff: Re: AW: Re: [Jython-dev] Clamp Development
>
> On Nov 2, 2009, at 3:42, "Jan Wedel" <Jan.Wedel@...> wrote:
>
> > Hi!
> >
> >> If you just want to use arbitrary Python modules in Jython without
> >> dynamic compilation and don't care about exposing them as Java
> >> classes, clamp isn't adding anything.  However, one of the things I
> >> added to Jython for clamp is the ability to specify where to store
> >> the
> >> bytecode Jython generates and that stored bytecode should be used
> >> instead of always dynamically generating it.  That should allow you
> >> to
> >> use 3rd party libs in a restricted environment.
> >
> > Do you mean Java byte code or Python byte code? If Python actually
> > generates Java byte code, where can I find it? Do you know any
> > documentation by chance, that explains how to generate Java class
> > files
> > or (in an optimal way) create a self-contained jar file from Python
> > code?
>
> It's java byte code.  Whenever you import a module with jython, it
> spits out  a $py.class file corresponding to the imported module in
> the same directory. You can use the compileall module included with
> jython to compile a whole directory tree and control where it's
> output.  After compiling everything, you no longer need the .py files.
> I think there are a couple guides on the wiki for doing this.
>
> However jython still generates java bytecode for proxy classes at
> runtime, even if the modules containing the proxy classes are
> precompiled. This is what the proxy generation branch takes care of.
>
> >> I'm a little worried about your desire for "native speed".  Jython
> is
> >> a decently fast implementation of Python, but it's not going to be
> as
> >> fast as plain Java code.  I don't have a good feel for what the
> ratio
> >> is of Java performance to Jython performance these days, especially
> >> for VMs other than Sun's, so I can't say how much slower Jython
will
> >> be.  What level of performance do you need?  Maybe someone else
here

> >> can give you an idea of how Jython will do.
> >
> > I've done some performance tests on my Python Interpreter. It runs
> > 200-300 times slower that the same program coded in "native" Java.
> > Hmm,
> > I think I'm still a bit confused about what Jython does.
> >
> > Is Jython "only" a Java implementation of the CPython interpreter?
> > That
> > would mean, you always need the whole Jython core/interpreter libs
to

> > create a self contained Jar file. Or, is Jython/Clamp able to create
> > "native" Java byte code without a Python Interpreter in between?
> >
> > Like this:
> > Python source -> Jython Interpreter -> Jython interprets code and
> > executes at runtime in a Java VM
> > Or more like this
> > Python source -> Java byte code -> Java Interpreter of the VM
> > interprets
> > byte code at runtime (Jython not necessary anymore)
>
> Jython creates bytecode that's run directly by the jvm, but much of
> the core pieces of python are implemented in java and are still needed
> by the generated bytecode.  Things like list, dict, int, str and so on
> are contained in jython's jar, so it's still needed by the compiled
> modules.  So jython isn't interpreting anything, but it still needs
> some core classes.
>
> Charlie
>



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: Clamp Development

by Charlie Groves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jan,

On Wed, Nov 4, 2009 at 11:48 PM, Jan Wedel <Jan.Wedel@...> wrote:
> I followed your advise, used compile all, built a JAR file containing
> the class and the whole Jython lib (I planned to stip it down when it's
> working) and then passed it to the Java ME emulator. But is sais "can'T
> find MIDlet class". Then I observed the Java byte code generated by
> Jython and saw that the resulting class is not implementing MIDlet but
> PyRunnable and an $1 has been added to the class name. I think, this
> makes it impossible for the emulator to run the MIDlet.

I'm sorry that came off as advice of something to do.  What I was
trying to say is that jython compiles modules to bytecode which can
then be executed without dynamic compilation by PythonInterpreter.
They aren't meant to run as regular Java classes as you saw; that's
what the proxy classes do.

> So, I have to admit that I'm not really sure what exactly the "proxy
> classes" you were talking about are doing. Alex Grönholm told me, that
> you have not finished to implement all proxy generation hooks. But what
> are they for? Do they act as correctly named interfaces to other native
> Java classes? Something like you generate one proxy class for each
> jython class that looks like a class how it should be in Java but which
> delivers the calls to subjacent jython classes / methods?

Yes, the proxy classes are the bridges between Java code and Python
code.  They implement Java interfaces and extend Java classes, and
when the methods they override are invoked, they know how to method
lookup on a Python instance and invoke the method there.

> If yes, then it really seems, that Clamp should solve my problem,
> shouldn't it?

Actually, clamp isn't needed for your use case.  Clamp lets you put
decorators on python classes to turn them into something callable from
Java.  If you're just trying to extend a Java class, you just need the
ability to statically compile and name those proxies.  Clamp needed
that as well, which is why the two keep getting conflated.

> Whatever, I already offered you my help. So if there is anything I could
> do, just say it. In your first mail, you explained that your work is
> half way done but it's still on your working copy and not committed yet.
> If you like, I'll be glad to have a look on the current code just to get
> an idea what you are doing and how I could possibly help. You could just
> send the important classes as a zip file to me. I doesn't have to work,
> I doesn't need to be compilable and fully commented, it's just to get an
> overview.

Well, the majority of the work is already available in the
customizable-proxymaker branch in the jython repository.  That already
contains the static compilation you need.  The bit that remains in my
local copy is a refactoring of it to allow the generators of proxies
to fill in whatever bytecode they like.  I think it's a better way to
expose all of this, but I've tried a few times over the past weeks to
get back to it and haven't been able to scrape together the time.  I
don't think the work in my local copy is in a state to be
comprehensible without a fair amount of explanation, but the stuff
committed to the branch compiles and works as far as I know.  If you
want to pick up from there and get it to a state that it's ready to be
merged back to trunk, that would be a way to move this forward.  I'd
love to get back to this at some point, but it doesn't look like
that's going to happen anytime soon, and I don't want to prevent
someone else from working on it.  The major work remaining there for
your use case is a) adding a tool to take advantage of the static
proxy compilation and b) using that to visit all the classes in the
standard lib that need it and make  static proxies for them.

Charlie

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: Clamp Development

by Charlie Groves :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jan,

On Tue, Nov 10, 2009 at 6:25 AM, Jan Wedel <Jan.Wedel@...> wrote:

> I guess you're busy right now, but I just want to clarify some things.
> To make a Jython class file run on a JavaME, they need to be compatible
> with CLDC and MIDP/IMP. That means the ClassLoader and e.g. JNI is not
> supported. Moreover, the APIs are very limited (see
> http://java.sun.com/javame/reference/apis/jsr118/). E.g., HashMap and
> Templates are not supported. Instead, Hashtable and type casting must be
> used. That means, there might be some work to do to make it compatible
> with JavaME. Can you approximate if there is a lot of code needs to be
> ported? Or even some parts that heavily depend on dynamic class loading
> (with can not be implemented in JaveME CLDC at all)? This is only
> important for all Jython/Clamp classes that are needed at runtime on the
> embedded environment and not interpreter or interactive promt stuff.

We do use HashMap and generics fairly heavily throughout the codebase.
 Also, the store for dicts is a ConcurrentHashMap, which while not a
HashMap, probably isn't supported either.  Since I've never done any
programming for JavaME, I'm not sure what else isn't available and
what additional effort would be needed.  It does sound like there
would be a decent amount of work in getting just those basic types
working.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev

Re: Clamp Development

by Jan Wedel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Actually, clamp isn't needed for your use case.  Clamp lets you put
> decorators on python classes to turn them into something callable from
> Java.  If you're just trying to extend a Java class, you just need the
> ability to statically compile and name those proxies.  Clamp needed
> that as well, which is why the two keep getting conflated.
>
> Well, the majority of the work is already available in the
> customizable-proxymaker branch in the jython repository.  That already
> contains the static compilation you need.  
> The major work remaining there for
> your use case is a) adding a tool to take advantage of the static
> proxy compilation and b) using that to visit all the classes in the
> standard lib that need it and make  static proxies for them.

Ah, Ok...I have a vague idea of what I could do. But still, despite the
fact that it's not completed yet, would't it be easier for me to use
clamp by adding annotations to the python code than to write new tools
to statically change the class proxies.

However, I checked out the code from the branch and I compiled it. But
what now? :) I know, to answer such a question would be very
time-consuming for you and you already drew a rough sketch. But I am
currently sitting in front of huge stack of source files and don't know
where to start. I would need some kind of entry point ;) Here are some
questions that fly around in my head:

1.) At first, to fulfill a) can I use the resulting jython.jar file from
that customizable-proxymaker branch build and create an external app? Or
do I have to somehow "hook" into the existing code? If yes, how would I
trigger that? By using compileall? What if I don't want to expose all
methods?
2.) I think I need to understand the code structure and hierarchy of
jython/proxymaker i.e. "what does what and when does it 'that'?" To do
that, could you please tell me which class is the main entry point for
the proxymaker? I saw that you modified some classes in the
org.python.exposed package but couldn't identify a main class from which
I could start studying...

Thanks in advance!

Jan



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jython-dev mailing list
Jython-dev@...
https://lists.sourceforge.net/lists/listinfo/jython-dev