Closed Turakar closed 9 years ago
Calling java code from lua is fairly easy.
findMethod(obj[1] --[[class]], "equals(Ljava/lang/Object;)Z" --[[method name]])[1](obj, otherObj)
Just make sure to check for thrown exceptions.
local method = findMethod(obj[1] --[[class]], "equals(Ljava/lang/Object;)Z" --[[method name]])
local retVal, exception = method[1](obj, otherObj)
if exception then
-- handle thrown exception, typically by throwing
return nil, exception
end
-- do stuff with retVal
Thx
I'm currently developing a Map based upon Lua tables, but there's currently a problem: The map javadoc says that two keys are considered the same if o1.equals(o2) yields true. This is easy to implement on java, but it's hard to implement in Lua, as you can't call Object.equals(). Is there a workaround or could this be fixed (we're actually talking in that case about calling Java code from Lua, and I don't know if this is a good thing...)