A High Performance Bridge for Lua and Java in Android
Luadroid is a high performace bridge for executing java code in lua in amdroid or exectuting lua code in android. Yeah, you can use luajava or luaj on other platforms. Its syntax is very similar to the original java syntax.
It supports try catch, synchronized, multi-thread, very simple cross-thread communication (auto-copied upvalues and a table like usedata to get and put variables ), autoboxing and auto-unboxing, class extension, interface implementation, class definition and so on. Method deduction and auto table conversion is supported also. Generic info will be considered during table conversion.
If there is no table conversion or function conversion, it will be only 4-5 times slower than java code at most even though the code is jited.If the java code is not jited, the consumption is ignorable. Class extension and definition are pretty heavy operations cause they need to generate a dex file and load it into the classloader.
GC for objects will be performed once the script is executed. GC for outdated thread is performed in javs gc thread.Note that due to Android O changes, it's no longer possible to test whether a thread is alive by pthread_kill so I use tgkill instead.However, in some extreme and weird cases(too many threads created and destoryed), it's not safe actually.
Both lua and luajit are supported.And the java type long will lose no precision in luajit cause when it will lose its precision, it will be converted to a usedata that overrides common mathmetic operators.
It's my personal project,so I can't make sure there's no bug even though I have performed a lot of tests. If you find any bugs or have any advice, please contact me.