Forum: JRuby API to invoke Java compilation

C19c27f3c5edb34542e4a906be116983?d=identicon&s=25 Federico Tomassetti (ftomassetti)
on 2013-11-13 10:41
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 (https://github.com/ftomassetti/jruby-javacompiler), I
would like just to avoid repeating something already done...

Federico
B97f192e676f1a67e0ef18f022671406?d=identicon&s=25 Rodrigo Botafogo (Guest)
on 2013-11-13 16:29
(Received via mailing list)
Federico,

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
C19c27f3c5edb34542e4a906be116983?d=identicon&s=25 Federico Tomassetti (ftomassetti)
on 2013-11-13 17:33
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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.