On Jul 30, 4: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?

More easily, you could use a Java constructor with variable argument
lists, see
http://developer.mozilla.org/en/docs/New_in_Rhino_1.6R6#Support_for_calling_Java_methods_and_constructors_with_variable_argument_lists

Will that work for you?

--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to