I am aware of the Java Scripting API (which runs scripts written in JavaScript, Groovy etc) and several expression languages (SpEL, JEXL, JUL). But it is possible to write scripts in Java itself and then invoke that script from Java code?
I found some information on compiling Java programmatically via the tools API but this not like scripting (i.e. the context is different).
I imagine something like this script being executed by my Java code:
int i = 42 + getFoo();
setBar(i);
Now - when invoked with a context that provides getFoo
and setBar
methods - it should evaluate i
and call the method.