I want to use the LLVM code generation Framework from Java.
I.e., I do not want to compile Java code into LLVM. I simply want an LLVM library for code generation that I can call from Java. The usual LLVM library is C, so I cannot use it.
Are there any Java ports? If no, what would be the easiest way to do it anyway? Wrap the API into JNI?
LLVM is publicly available under an open source License. Also, you might want to check out the new features in Git that will appear in the next LLVM release. If you want them early, download LLVM through anonymous Git.
Status (December 2019) All translations from Java to LLVM IR are complete. This means that all Java 7 language features---expressions, control flow, exceptions, method dispatch, switch statements, try-with-resources, initializer blocks, implicit type conversions, etc.
LLVM isn't a virtual machine. LLVM is not a virtual machine. It's a compiler infrastructure.
Scala Native's key is the compiler generating LLVM intermediate representation, used to produce efficient platform-dependent machine code.
A quick search for llvm java api bindings turned out several projects that seem like a good fit:
All of those libraries use JNI to access the C-API, so you have a DLL or SO file of the LLVM itself in any case.
To answer the question with more up-to-date information based on the current LLVM v3.6. Your options are:
If GPL licensing is OK with you, then you should definitely go for RoboVM. It's an active project with robust support for the latest LLVM version. JLLVM and LLVM-J are no longer active so you will need to do some extra work using them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With