You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Paul Hammant <Pa...@yahoo.com> on 2002/01/08 10:28:17 UTC

Re: [Fwd: Re: org.apache.cocoon.components.language.programming.java package]

Peter,

>>I don't know if it is replaced by another class/entry point, I just know
>>that when I use JDK 1.4 I get a deprecation warnings when compiling the
>>classes.
>>
>>Invoking compilers dynamically has always been a bit of a hack, because
>>
>>there is no direct interface to the compiler class--you have to go through
>>the command line.  Any time you rely on com.sun.* you run the risk of
>>seeing the classes change due to restructuring.  There is no contract
>>beyond what they expose to you (i.e. the command line).
>>
>>Also, the Jikes compiler works quite well....
>>
>
>Another idea maybe refactoring the ant stuff re compiling.
>
Is this an option dude?  Could the Ant javac invoker be used as it (i.e. 
instantiating org.apache.tools.ant.taskdefs.Javac and execute()ing it in 
situ) ?  Could it be that your forthcoming myrmidon is worth waiting for?

We really need the ability to compile Java on the server side of 
AvalonDB ....

Regards,

- Paul H


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Fwd: Re: org.apache.cocoon.components.language.programming.java package]

Posted by Peter Donald <pe...@apache.org>.
On Tue, 8 Jan 2002 20:28, Paul Hammant wrote:
> Is this an option dude? 

depends on how long you can wait ;)

I have already partially redone native executable launching - you can have a 
look at the code in

myrmidon/src/java/org/apache/myrmidon/framework/exec

Specifically at the ExecManager and ExecMetaData classes. This is a similar 
pattern which I will do with javac functionality.

Anyways I plan to do a similar service for Java launching and then after that 
a similar service for Javac. However there could be a while to wait - no idea 
on time frames ... unless of course you wanted to help ;)

However for the time being I would just cobble something together that works 
- myrmidon will eventually get there but it is not there yet and wont be 
there for a while.

> Could the Ant javac invoker be used as it (i.e.
> instantiating org.apache.tools.ant.taskdefs.Javac and execute()ing it in
> situ) ?

Maybe - not sure ;)

>  Could it be that your forthcoming myrmidon is worth waiting for?

maybe for use eventually - maybe just hack bits together in meantime or 
plunder from Cocoon which I believe has javac/jikes compilation in it.

-- 
Cheers,

Pete

---------------------------------------------
 We shall not cease from exploration, and the 
  end of all our exploring will be to arrive 
 where we started and know the place for the 
        first time -- T.S. Eliot
---------------------------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [Fwd: Re: org.apache.cocoon.components.language.programming.java package]

Posted by Paulo Gaspar <pa...@krankikom.de>.
> If it is compiled, I need a way of 1) persisting the class ( get at it's 
> byte[] bytecode ) so that I can 2) transport the class.  The thinking is 
> that for some configurations of AvalonDB, the server may prefer to ask 
> another for the 'compiled select statement'.

Keep in mind that Pnuts source code is available.

But maybe you only need source to better understand the not so good docs.
Pnuts was developed at Sun Japan and their English is not always cristal
clear.

I found several clues that what you want should be possible and simple:
  - The compiler class:
      http://javacenter.sun.co.jp/pnuts/apidoc/pnuts/compiler/Compiler.html

    It has several interesting methods, like these parser methods:
        public Pnuts compile(java.lang.String expression)
        public Pnuts compile(java.lang.String expression, Context context)

    ...and this compiler method:
        public java.lang.Object compile(Pnuts pnuts, ClassFileHandler handler)

    ...which uses a ClassFileHandler to stream the classes:
        http://javacenter.sun.co.jp/pnuts/apidoc/pnuts/compiler/ClassFileHandler.html

    ...and looking at the source of one of the implementations you should
       understand better how to use it:
        http://javacenter.sun.co.jp/pnuts/apidoc/pnuts/compiler/FileWriterHandler.html

  - But the best way of understanding how this works is looking at the
    commandline compiler:
        http://javacenter.sun.co.jp/pnuts/doc/pnutsc.html

    Also pay attention to the source code it generates for running the
    compiled code. It looks like it still has dependencies on some Pnuts
    classes... but maybe those classes are small enough to fit your 
    iPaq! =;o)

  - Also notice that when using the CachedPnutsImpl:
        http://javacenter.sun.co.jp/pnuts/apidoc/pnuts/ext/CachedPnutsImpl.html

    ...as in
        pkg = new pnuts.lang.Package();
        ctx = new Context(pkg);
        ctx.setPnutsImpl(new CachedPnutsImpl());

    even an eval call like this:
        int[] vv = {0,1010101,2,3,4,5,6,7,8};
        pkg.set("x", vv, ctx);
        Object res = Pnuts.eval("x[1] + x[2] + x[3] + x[4]", ctx);

    will use a cached compiled version of that script String if there
    is already one, and that makes things MUCH faster. 

    Maybe checking the code of CachedPnutsImpl also helps.


This are the clues. Play with the thing.

I find it much simpler to use than Rhino.


Have fun,
Paulo Gaspar


> -----Original Message-----
> From: Paul Hammant [mailto:Paul_Hammant@yahoo.com]
> Sent: Tuesday, January 08, 2002 5:53 PM
> To: Avalon Developers List
> Subject: Re: [Fwd: Re:
> org.apache.cocoon.components.language.programming.java package]
> 
> 
> Paulo,
> 
> >>We really need the ability to compile Java on the server side of 
> >>AvalonDB ....
> >>
> >
> >I do not know if this could help but...
> >
> >
> >Pnuts is a Java-like scripting language that compiles into memory
> >without using a Java compiler:
> >  http://javacenter.sun.co.jp/pnuts/
> >
> This sounds great.  I think I may try it with the 'basic' parser.  It 
> currently uses Rhino, but there is no reason why we could not abandon 
> JavaScript (I joke you not) for some faster impl.
> 
> >It is pure Java and my performance tests hint that it really has to
> >be compiled as they announce - it is so damn fast!!!
> >  http://javacenter.sun.co.jp/pnuts/doc/pnuts_engine.html
> >
> If it is compiled, I need a way of 1) persisting the class ( get at it's 
> byte[] bytecode ) so that I can 2) transport the class.  The thinking is 
> that for some configurations of AvalonDB, the server may prefer to ask 
> another for the 'compiled select statement'.  This sounds daft so I'll 
> exlain more.  What we want is a facility to turn 'Select * from People 
> where name like "Fred%" ' into a generated RowTester class that does ->
> 
>  Class123 extends RowTester {
>     boolean testRow(Row row) {
>         return (
>             row.getValue("name").startsWith("Fred");
>         );
>     }
>  }
> 
> With the 'basic' impl we are doing testRow() in JavaScript (and it 
> works).  If we can compile Select statements into classes (true 
> bytecode) they can be thrown around a cluster of AvalonDBs or even 
> pre-added to a resource limited machine (yer must know that I want to 
> get Avalon running in my iPAQ).
> 
> >It integrates VERY well with Java.
> >
> >< license snipped >
> >
> >I see no problems in the license but I am far from being an expert.
> >Read it if you are interested. It is not so big.
> >
> License is fine.  Very unrestrictuive for a Sun license.
> 
> Regards,
> 
> - Paul H
> 
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Fwd: Re: org.apache.cocoon.components.language.programming.java package]

Posted by Paul Hammant <Pa...@yahoo.com>.
Paulo,

>>We really need the ability to compile Java on the server side of 
>>AvalonDB ....
>>
>
>I do not know if this could help but...
>
>
>Pnuts is a Java-like scripting language that compiles into memory
>without using a Java compiler:
>  http://javacenter.sun.co.jp/pnuts/
>
This sounds great.  I think I may try it with the 'basic' parser.  It 
currently uses Rhino, but there is no reason why we could not abandon 
JavaScript (I joke you not) for some faster impl.

>It is pure Java and my performance tests hint that it really has to
>be compiled as they announce - it is so damn fast!!!
>  http://javacenter.sun.co.jp/pnuts/doc/pnuts_engine.html
>
If it is compiled, I need a way of 1) persisting the class ( get at it's 
byte[] bytecode ) so that I can 2) transport the class.  The thinking is 
that for some configurations of AvalonDB, the server may prefer to ask 
another for the 'compiled select statement'.  This sounds daft so I'll 
exlain more.  What we want is a facility to turn 'Select * from People 
where name like "Fred%" ' into a generated RowTester class that does ->

 Class123 extends RowTester {
    boolean testRow(Row row) {
        return (
            row.getValue("name").startsWith("Fred");
        );
    }
 }

With the 'basic' impl we are doing testRow() in JavaScript (and it 
works).  If we can compile Select statements into classes (true 
bytecode) they can be thrown around a cluster of AvalonDBs or even 
pre-added to a resource limited machine (yer must know that I want to 
get Avalon running in my iPAQ).

>It integrates VERY well with Java.
>
>< license snipped >
>
>I see no problems in the license but I am far from being an expert.
>Read it if you are interested. It is not so big.
>
License is fine.  Very unrestrictuive for a Sun license.

Regards,

- Paul H

>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [Fwd: Re: org.apache.cocoon.components.language.programming.java package]

Posted by Paulo Gaspar <pa...@krankikom.de>.
> We really need the ability to compile Java on the server side of 
> AvalonDB ....

I do not know if this could help but...


Pnuts is a Java-like scripting language that compiles into memory
without using a Java compiler:
  http://javacenter.sun.co.jp/pnuts/

It is pure Java and my performance tests hint that it really has to
be compiled as they announce - it is so damn fast!!!
  http://javacenter.sun.co.jp/pnuts/doc/pnuts_engine.html

It integrates VERY well with Java.


It is Open Source, Sun License:
  http://javacenter.sun.co.jp/pnuts/LICENSE.txt

You can distribute it:
  Sun grants Licensee a non-exclusive, royalty-free right to download, 
  install, compile, use, copy and distribute this Software, modify or 
  otherwise create derivative works from the Software (each, a 
  "Modification") and distribute any Modification to its customers 
  with a license agreement containing these terms. 

I see no problems in the license but I am far from being an expert.
Read it if you are interested. It is not so big.


Have fun,
Paulo Gaspar


> -----Original Message-----
> From: Paul Hammant [mailto:Paul_Hammant@yahoo.com]
> Sent: Tuesday, January 08, 2002 10:28 AM
> To: Avalon Developers List
> Subject: Re: [Fwd: Re:
> org.apache.cocoon.components.language.programming.java package]
> 
> 
> Peter,
> 
> >>I don't know if it is replaced by another class/entry point, I just know
> >>that when I use JDK 1.4 I get a deprecation warnings when compiling the
> >>classes.
> >>
> >>Invoking compilers dynamically has always been a bit of a hack, because
> >>
> >>there is no direct interface to the compiler class--you have to 
> go through
> >>the command line.  Any time you rely on com.sun.* you run the risk of
> >>seeing the classes change due to restructuring.  There is no contract
> >>beyond what they expose to you (i.e. the command line).
> >>
> >>Also, the Jikes compiler works quite well....
> >>
> >
> >Another idea maybe refactoring the ant stuff re compiling.
> >
> Is this an option dude?  Could the Ant javac invoker be used as it (i.e. 
> instantiating org.apache.tools.ant.taskdefs.Javac and execute()ing it in 
> situ) ?  Could it be that your forthcoming myrmidon is worth waiting for?
> 
> We really need the ability to compile Java on the server side of 
> AvalonDB ....
> 
> Regards,
> 
> - Paul H


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>