In a previous message on this list, you said that using reflection
intead of generating byte-codes allows the BeanShell implementation
to be simpler. Simple is good.
How much complexity would it add to allow BeanShell to emit
Java source code that javac could compile?
This lends itself to a more type-safe interface that seems
very natural when calling BeanShell from Java. I'm thinking
about something along the lines of this method:
Object compile(Class interfaces, String bshSource);
where the Object returned implements the given interfaces.
If no Java compiler is available, then BeanShell would know the
user intended to re-use the code, but would be unable to compile it.
So, the "compiled" code would run the same, only more slowly.
Also, an implicit compiling interface could be used ala HotSpot.
More specifically, source code given to the interpreter for evaluation
could be compared against previously evaluated code. Frequently
evaluated code could be sent to javac.
I'm sure this means adding a large amount of code, but it seems
that with some careful design, the impact to the current BeanShell
code could be minimal. The distribution might even be split into
versions with and without the compiler included.
How hard would this be?
Would it be worth the effort?