[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LuaJava - creating arrays
- From: Aaron Kamienski <aaronk@...>
- Date: Tue, 27 Jun 2000 17:48:05 -0500
Hello,
I'm trying to create a Java array from Lua (or, probably more
precisely, a Lua proxy for a Java array). However, I am having
problems and wonder if anyone might have suggestions.
Not seeing a Lua method that provides for this directly, I thought I
would try something like the following:
Array = javaBindClass("java.lang.reflect.Array")
Object = javaBindClass("java.lang.Object")
an_array = Array:newInstance(Object, 10)
This doesn't work. It generally causes java to crash with the
following message:
JNI panic: JNI received a null string
at lua.API.doString(API.java:221)
at Lua.main(Lua.java:27)
If I run java from within jdb, I can get this nice little stack
dump:
Uncaught exception: java.lang.VerifyError at
java.lang.ClassLoader.resolve
Class(ClassLoader.java:237)
at lua.LuaWrapperBuilder.loadClass(LuaWrapperBuilder.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:154)
at lua.ToLua.createLuaWrapper(ToLua.java:880)
at lua.ToLua.tryMatch(ToLua.java:818)
at lua.ToLua.getMatchingMethod(ToLua.java:746)
at lua.ToLua.access$12(ToLua.java:738)
at lua.ToLua$13.foo(ToLua.java:707)
at lua.API.doString(API.java:221)
at Lua.main(Lua.java:27)
In the lua.LuaWrapperBuilder.loadClass method, the code is following
the path that has it call buildWrapper(), and defineClass(). The
cls it is trying to build is ClassWrapperForLua.
With the java -v (verbose) switch I get the following output:
[Resolving ClassWrapperForLua]
VERIFIER CLASS ERROR ClassWrapperForLua:
Class ClassWrapperForLua is subclass of final class java/lang/Class
Could this be the problem? The verifier is complaining because this
generated class is subclassing a final class? (It certainly doesn't
have any problems with other classes - e.g., ActionListener.)
With java -noverify I get the following:
lua error: java.lang.reflect.Array.newInstance:
java.lang.Class.<init>()V
Active Stack:
(C code)
main of file `javaarray.lua'
function `dofile' [(C code)]
main of string `dofile "javaarray.lua"'
I would appreciate any pointers (e.g., the correct way to create arrays,
what is wrong with this method, why does the ClassLoader think
that this is an invalid class, how to work around this error, etc.).
Thanks,
ajk
PS - BTW, I am using Lua 3.2.2 and JDK 1.1.8
PPS - This is my first post to the ML, so I need to mention that
I think Lua is great! Thanks!