On Jul 30, 1:22 pm, Ivan Voras <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to create a Java class that will be used in JS with a
> varargs constructor.
>
> As I understand it, I can't declare a jsConstructor and have it work
> with varargs. The next thing I tried was, following the documentation
> of FunctionObject, to create a constructor with the arguments (Context
> cx, Object[] args, Function ctorObj, boolean inNewExpr), create a
> FunctionObject for this constructor and add it with scope.put(). This
> also doesn't work: I get a ClassCastException in the JS line that
> creates the object: something tries to cast the new class object to
> the class of the scope it's in (and they're unrelated - thus the
> exception).
>
> As an alternative, I see the addAsConstructor() method of the
> FunctionObject but whatever I give as the prototype argument makes it
> fail in different ways.
>
> So, how to create a hosted Java class accessible to the JS code with a
> varargs constructor?

There is also an extended form of jsConstructor which includes a list
args.
    public static Scriptable jsConstructor(Context cx, Object[] args,
Function ctorObj, boolean inNewExpr);
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to