Subj : Re: org.mozilla.javascript.EvaluatorException: Can't convert to type To : mesuti@aciworldwide.com From : Igor Bukanov Date : Wed Feb 25 2004 04:54 pm This should be fixed in the forthcoming Rhino 1.5 Release 5, you may try release candidate 1 to see if it works for you indeed, http://www.mozilla.org/rhino/download.html . As a workaround for the previous releases you will need to change the argument type in jsFunction_concat to Scriptable and do manual casting. Regards, Igor mesuti@aciworldwide.com wrote: > > > > Hi, > > I want to use Rhino interpreter in a Smart Card Management system as ECMA > script interpreter. Rhino throws an exception when I call concat() method > of a Host Object that I implemented (ByteString). A part of the source code > can be seen below: > > > > public class ByteString extends ScriptableObject { > > /** Creates a new instance of ByteString */ > public ByteString() { > } > > public void jsConstructor(String s, Integer enc) { > ... > } > > public int jsGet_length() { > ... > } > > public ByteString jsFunction_concat(ByteString bs) throws IOException { > ByteString bs1 = new ByteString(); > ... > > return bs1; > } > > public String getClassName() { > return "ByteString"; > } > } > > > Sample JavaScript calling the concat method is also given below: > > var tmpA = new ByteString("Text1 ", ASCII); > var tmpB = new ByteString("Text2", ASCII); > var tmpC = tmpA.concat(tmpB); // this is the problem line > > > When Rhino evaluates the script it throws the following exception: > > Evaluating JavScript D:\Data\Archive\Rhino-15R41\experiments\sample.js... > org.mozilla.javascript.EvaluatorException: Can't convert to type > "com.bla1.bla2.bla3.hostobjects.ByteString". > (D:\Data\Archive\Rhino-15R41\experiments\sample.js; line 3) > at > org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:76) > at > org.mozilla.javascript.Context.reportRuntimeError(Context.java:591) > at > org.mozilla.javascript.Context.reportRuntimeError(Context.java:630) > at > org.mozilla.javascript.Context.reportRuntimeError1(Context.java:606) > at > org.mozilla.javascript.FunctionObject.convertArg(FunctionObject.java:359) > at > org.mozilla.javascript.FunctionObject.call(FunctionObject.java:408) > at > org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191) > at > org.mozilla.javascript.gen.c1.call(D:\Data\Archive\Rhino-15R41\experiments\sample.js:3) > at > org.mozilla.javascript.gen.c1.exec(D:\Data\Archive\Rhino-15R41\experiments\sample.js) > at org.mozilla.javascript.Context.evaluateReader(Context.java:820) > at > com.aciworldwide.scm.gp.JSInterpreter.(JSInterpreter.java:64) > at > com.aciworldwide.scm.gp.JSInterpreter.main(JSInterpreter.java:117) > > > It seems all methods with a "ByteString" argument causes the same problem. > > Thanks > > Ishak > .