ikws4 / WeiJu2-Scripts

MIT License
26 stars 2 forks source link

Create Java arrays #6

Open kiber-io opened 6 months ago

kiber-io commented 6 months ago

There is a method in Java:

public static void test(Object ... args) {}

How can I call it from lua? I tried various methods, but none worked:

test({}}
-- Error: attempt to call a nill value
test(luajava.newInstance("[Ljava.lang.Object;")
-- Error: vm error: java.lang.NullPointerException: Attempt to invoke virtual method 'org.luaj.vm2.Varargs org.luaj.vm2.LuaValue.invoke(org.luaj.vm2.Varargs)' on a null object reference
test(luajava.newInstance("[Ljava.lang.Object;", 1)
-- Error: vm error: java.lang.NullPointerException: Attempt to invoke virtual method 'org.luaj.vm2.Varargs org.luaj.vm2.LuaValue.invoke(org.luaj.vm2.Varargs)' on a null object reference