On Jul 30, 11:43 pm, Norris Boyd <[EMAIL PROTECTED]> wrote: > 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, > seehttp://developer.mozilla.org/en/docs/New_in_Rhino_1.6R6#Support_for_c... > > Will that work for you?
If you mean define a jsConstructor with varargs argument, like "public void jsConstructor(Object ... args)", then no, it doesn't work. The exception I get is "Unsupported parameter type "[Ljava.lang.Object;" in method "jsConstructor"." This is Rhino 1.7. _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
