alicorn-systems/v8-adapter

Bug with static methods in javascript to java linker(v8JavaStaticMethodProxy)

Opened this issue · 0 comments

here is an expected error message

undefined:1: Wrong number of arguments; expected 2*, got 0

*any number for a method with more params than 0.

the cause is at line 45 of V8JavaStaticMethodProxy with the following statement.
return V8JavaObjectUtils.translateJavaArgumentToJavascript(coercedMethod.invoke(coercedArguments), V8JavaObjectUtils.getRuntimeSarcastically(receiver), cache);

to be specific, coercedMethod.invoke(coercedArguments) is improper call for a static method.

the following coercedMethod.invoke(null,coercedArguments) I suspect will have the desired effect for static methods with parameters.

with Method.invoke, the first parameter is a live (non static) object of a class, if it is null, it will default to a static methods only of said class. the second parameter(or v varargs if you rather call it) is all the passed variables for the method.