| Andreas Rozek | |
|
|
|
LuaJava_07 - can Java detect the original type of Lua values?When LuaJava is used to invoke Java methods, some of the given (Lua) arguments will be converted, others will not. Is it possible to detect the original type of an (unconverted) Lua argument? LuaJava_07 goes further into this question.
Please, also consider my "Hints for Reading"
and the "List of Recent Changes"! |
LuaJava_07
The script itself is extremely simple and should not require any further
explanation. The accompanying Java source may be compiled using javac LuaJava_07.java and will (again) need the luajava package. The resulting class file should be copied to a place where it can be found by the Java class loader (e.g., into a directory which is automatically scanned by the Java extension mechanism).
After an invocation of the form java luna.LuaJava LuaJava_07.lua the script produces the following output
LuaJava_07 - can Java detect the original Lua type?
Lua2Java(nil) -> null (null)
Lua2Java(true) -> java.lang.Boolean(true)
Lua2Java(123.456) -> java.lang.Integer(123)
Lua2Java('Test') -> java.lang.String(Test)
Lua2Java({}) -> Lua Table (Lua Table)
Lua2Java(function() end) -> Lua Function (Lua Function)
Some details are worth mentioning:
|
Source CodeThe source code of this script and its accompanying Java class is publically available: |
DisclaimerPlease, also consider the author's Disclaimer! |
|
|
|
| http://www.Andreas-Rozek.de/LuaJava/Acquainting/LuaJava_07_en.html | (last Modification: 26.11.2004) |