Bcel version problem when using LuaJC in multi Thread #85
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I tried to use LuaJC in the situation of multi thread but got failed.
Problems
I used the official case referring to http://www.luaj.org/luaj/3.0/examples/jse/SampleMultiThreaded.java, and I just added one line code 'LuaJC.install(g);' after the initialization of Globals,just like the code below.
But the result is always wrong with Exception:
Exception in thread "Runner-0" java.lang.ClassFormatError: Invalid length 65535 in LocalVariableTable in class file lua_hello$sayHello at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.lang.ClassLoader.defineClass(ClassLoader.java:642) at org.luaj.vm2.luajc.JavaLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671) at java.lang.Class.getConstructor0(Class.java:3075) at java.lang.Class.newInstance(Class.java:412) at org.luaj.vm2.luajc.JavaLoader.load(Unknown Source) at org.luaj.vm2.luajc.JavaLoader.load(Unknown Source) at org.luaj.vm2.luajc.JavaLoader.load(Unknown Source) at org.luaj.vm2.luajc.LuaJC.load(Unknown Source) at org.luaj.vm2.Globals.load(Unknown Source) at org.luaj.vm2.Globals.loadfile(Unknown Source) at cn.xzxy.lewy.luaj.SampleMultiThreaded$Runner.run(SampleMultiThreaded.java:40) at java.lang.Thread.run(Thread.java:748)So,I gusse there is a problem when bcel complies the same lua file in multi thread situation.
Solutions
After tough attempts,I find two solutions.
Conclusion
According to the introduction of official website, the bcel-5.2.jar is the first we know.
java -cp "lib/luaj-jse-3.0.1.jar;lib/bcel-5.2.jar" lua -b examples/lua/hello.luaBut bcel-5.2.jar can only work when we use LuaJC in single thread situation. We should use the version of
6.5.0to deal with multi thread.Finally,LuaJC is indeed the better way that java program calls lua script.
We updated bcel