diff --git a/src/jse/org/luaj/vm2/lib/jse/CoerceJavaToLua.java b/src/jse/org/luaj/vm2/lib/jse/CoerceJavaToLua.java index b0a710c6..48655618 100644 --- a/src/jse/org/luaj/vm2/lib/jse/CoerceJavaToLua.java +++ b/src/jse/org/luaj/vm2/lib/jse/CoerceJavaToLua.java @@ -36,7 +36,7 @@ public class CoerceJavaToLua { public LuaValue coerce( Object javaValue ); }; - private static Map COERCIONS = new HashMap(); + static final Map COERCIONS = new HashMap(); static { Coercion boolCoercion = new Coercion() { diff --git a/src/jse/org/luaj/vm2/lib/jse/CoerceLuaToJava.java b/src/jse/org/luaj/vm2/lib/jse/CoerceLuaToJava.java index 3e0e4092..e5772c2c 100644 --- a/src/jse/org/luaj/vm2/lib/jse/CoerceLuaToJava.java +++ b/src/jse/org/luaj/vm2/lib/jse/CoerceLuaToJava.java @@ -37,8 +37,7 @@ public class CoerceLuaToJava { public int score( int paramType ); }; - private static Map COERCIONS = new HashMap(); - private static Coercion OBJECT_COERCION; + static final Map COERCIONS = new HashMap(); static { Coercion boolCoercion = new Coercion() { @@ -232,7 +231,7 @@ public class CoerceLuaToJava { /** Score a single parameter, including array handling */ - private static int scoreParam(int paramType, Class c) { + static int scoreParam(int paramType, Class c) { if ( paramType == LuaValue.TUSERDATA && !c.isArray() ) return 0; Coercion co = (Coercion) COERCIONS.get( c ); @@ -277,11 +276,23 @@ public class CoerceLuaToJava { throw new LuaError("no coercion found for "+a.getClass()+" to "+c); } - static Object[] coerceArgs(Varargs suppliedArgs, Class[] parameterTypes) { + static Object[] coerceArgs(Varargs suppliedArgs, Class[] parameterTypes, boolean isvarargs) { + int nsupplied = suppliedArgs.narg(); int n = parameterTypes.length; + int nplain = Math.min(isvarargs? n-1: n, nsupplied); Object[] args = new Object[n]; - for ( int i=0; i