Hi,
I wonder if there is any API in JRuby to invoke the Java compiler.
I would like to load some Java source file, compile it on the fly and
run it. I am ware of the Java Compiler API and I was about to wrap it in
a new project (GitHub - ftomassetti/jruby-javacompiler: Compile Java programmatically from JRuby), I
would like just to avoid repeating something already done…
Ive looked a lot at this type of API and couldnt find anything. I
presumed that there is no such library for JRuby. I wanted to use this
for
MDArray, but left it for a future versions. I think that an easy to use
on
the fly compiler will be great for JRuby. The easiest compiler I found
was
Janino. The Java Compiler API, if Im not mistaken, requires the
creation
of a file and then reads this file (seemed like a lot of work and could
have security implications). Janino, I believe, does this without the
file
creation.
Good luck!
Rodrigo
On Wed, Nov 13, 2013 at 7:41 AM, Federico Tomassetti
I think you can use the Compiler API to work in memory: you have to
crate some dummy classes representing a Java source file which are not
tied to a real file but just have the code in memory. The problem with
Compiler API on my side is that they requires the JDK. I don’t like that
much the idea to be dependent on the configuration of the user.
I would consider ASM, CGLIB and this Janino that you suggest.
If you are interested I could use an helping hand on that
Federico
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.