views:

535

answers:

3

Is there a way to run plain c code on top of the JVM?
Not connect via JNI, running, like you can run ruby code via JRuby, or javascript via Rhino.

If there is no current solution, what would you recommend I should do?
Obviously I want to use as many partials solutions as I can to make it happen.

ANTLR seems like a good place to start, having a full "ANSI C" grammar implementation...
should I build a "toy" VM over the JVM using ANTLR generated code?

+5  A: 

Maybe not exactly what you need but a commercial option is http://www.axiomsol.com/

Paulo Lopes
+4  A: 

Yes.

Here's a commercial C compiler that produces JVM bytecode.

joel.neely
+2  A: 

There are two other possibilities, both open-source:

JPC emulates an entire x86 pc within the JVM, and is capable of running both DOS and Linux.

NestedVM provides binary translation for Java Bytecode. This is done by having GCC compile to a MIPS binary which is then translated to a Java class file. Hence any application written in C, C++, Fortran, or any other language supported by GCC can be run in 100% pure Java with no source changes.

rasjidw