convert java to c by llvm


my c++ code have to call some functions coded by java. In the beginning, I call those functions by jni.
Unfortunately, jni has lots of performance loss, so it can’t meets my needs.

I wandor if I can convert these java codes to c/c++ by llvm. First, I convert java words to llvm bytecode, then covert llvm bytecodes to c/c++.

I am a green hand of LLVM and compilers. So tt’s very appreciated if someone told me if the idea is feasible or how to do it.


Hi Lu Lu,

It’s feasible, that’s what I do to link MMTk (a Java framework for garbage collection) written in Java with VMKit’s Java runtime written in C++. To translate the Java code to llvm IR, it uses the compiler in VMKit.

The code to compile is quite tailored for VMKit needs, but it still shows that you can avoid JNI calls doing it this way.

You can take a look at VMKit here:


2011/7/7 lu lu <>