javac code generator based java source interpreter, then... genuine scripted Java language

Compl Yue Still complystill at gmail.com
Thu Jul 5 14:19:46 PDT 2007


Hi Peter,

Thanks for the quick and informative reply, I didn't get to this
example before, and it seems very promising.

But my concern is still about interactivly executing Java statements,
like scrirpts, idealy like in a Shell (with word completion etc.),
This is why I'd been considering BeanShell at the beginning.

I havn't walked close enough to the Java Compiler API based approach
so far, mainly in worries about Java class loading. I often heard JSP
containers run OutOfMemory with default size for perm gen of heap,
while the main heap is still free, simply because frequently
recompiling of JSP pages i.e. class loading.

I quite like the example you showed here, since it will just do
EXACTLY what an state-of-the-art JVM does, but I'm still afraid of
such an implementation within a long-run app-server JVM will cause
problems sooner or later. I'm expecting positive opinions from you
regarding your expertise in all these around.

And another issue with this approache come to me that to prompt user
inputs from an interactive shell, where complex constructs beyond
simple expressions should be allowed, like for() loops etc. An AST
parser knows well whether it has received enough input as to construct
an evaluable node, but how could my code deal with that when it's not
doing parsing jobs? One single line expression a time is not enough
for it to be really useful.

Best Regards,
Compl

On 7/6/07, Peter Ahé <peter at ahe.dk> wrote:
> I don't understand why you want to interpret, the JVM is good at that.
>  Consider using the approach of this demo which compiles and evaluates
> Java expressions:
>
> https://ksl.dev.java.net/source/browse/ksl/trunk/compiler/test/tools/javac/api/evalexpr/
>
> Cheers,
> Peter
>


More information about the compiler-dev mailing list