luaj / luaj

Lightweight, fast, Java-centric Lua interpreter written for JME and JSE, with string, table, package, math, io, os, debug, coroutine & luajava libraries, JSR-223 bindings, all metatags, weak tables and unique direct lua-to-java-bytecode compiling.
http://luaj.sourceforge.net/
MIT License
919 stars 175 forks source link

Luaj Use java run the lua sprite, and Calling the Java object backwards is NULL #101

Open Yecgaa1 opened 2 years ago

Yecgaa1 commented 2 years ago

1

I use debugging, and I'm pretty sure the code will execute to get there. but Does it seem impossible to call Java backwards in a Lua script, but create a completely new JVM? Otherwise why do I call all variables null, even if it's static. Did I miss any important code? Or do I have a problem with my intentions?

dianwangwin commented 2 years ago

me too and i dont know what happened

dianwangwin commented 2 years ago

1

I use debugging, and I'm pretty sure the code will execute to get there. but Does it seem impossible to call Java backwards in a Lua script, but create a completely new JVM? Otherwise why do I call all variables null, even if it's static. Did I miss any important code? Or do I have a problem with my intentions?

可能是Class Loader的问题

orange451 commented 2 years ago

I would suggest calling the load() method from Globals, instead of loadFile(). This means you have to write your own file-reading code. It will help in debugging why it cannot load your script.

Additionally, in my implementation, I use the invoke() method instead of call() method.

-- 在Globals里面应该用的是Globals#load()。不要用Globals#loadFile()。 还有一个就是,在我的APP里面,我不用LuaFunction#call(), 我用的是LuaFunction#invoke()