how viable is it to port a C++ application to Java bytecode using LLVM (I guess LLJVM)?
The thing is that we currently have a process written in C++ but a new client has made mandatory to been able to run the program in a multiplatform way, using the Java Virtual Machine with obviously no native code (no JNI). The idea is to be able to take the generated jar and copy then to different systems (Linux, Win, 32 bits - 64 bits) and it should just work.
Looking around looks like it is possible to compile C++ to LLVM IR code and then that code to java bytecode. There is no need of the generated code to be readable.
I have test a bit with similar things using emscripten, this takes C++ code and compile it to JavaScript. The result is valid JS but totally unreadable (looks like assambler).
- Does anybody done a port of an application from C++ to Java bytecode using this tecnique?
- What problems could we face?
- Is a valid approach for production code?
To make more clear my point after some comments, maybe port is not well used, I do not expect readable source code as a result, just java bytecode, so it is not a 'port' which will be developed for anymore, just that the target plattform must be the java JVM not the native assamblear.
Note: I am aware that currently we have some non standard C++ and close source libraries, we are looking to removing this non standard code and all close source libraries and use Free Libre Open Source Software, so lets suppose all code is standard C++ code with all code available at compile time.
Note2: It is not an option to write portable C++ code and then compile it to the desired target platform, the compiled program must be multiplatform, thus the use of JVM .
Note3: Right now we are not looking into similar solutions applied to Python or other language base, but i would also like to heard about it. With this I mean that our target executable must be java bytecode but if there are options to compile C++ to valid python compiled code I would also like to hear about them.