Subj : Re: org.mozilla.javascript.EvaluatorException: Can't convert to type To : netscape.public.mozilla.jseng From : mesuti@aciworldwide.com Date : Thu Feb 26 2004 10:00 am Thank you very much for the tip Igor. The problem is solved in Rhino 1.5R5 Release Candidate 1. But I've got onother problem when I use the result object of the concat() method in the Java Script. JavaScript sample I used: //----------------------------------------------------- var tmpA = new ByteString("Ishak ", ASCII); var tmpB = new ByteString("Mesut", ASCII); var tmpC = tmpA.concat(tmpB); var tmpD = tmpC.concat(tmpA); //data.de_int = tmpC.length; data.output = tmpD; //data.output = tmpC.toString(ASCII); //End of Java Script //----------------------------------------------------- Rhino throws the following Exception: Evaluating JavScript D:\Data\Archive\Rhino-15R41\experiments\sample.js... concat result: Ishak Mesut TypeError: undefined is not a function. (D:\Data\Archive\Rhino-15R41\experiments\sample.js; line 4) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:2257) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:2247) at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:2270) at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1437) at org.mozilla.javascript.gen.c1._c0(D:\Data\Archive\Rhino-15R41\experiments\sample.js:4) at org.mozilla.javascript.gen.c1.call(D:\Data\Archive\Rhino-15R41\experiments\sample.js) at org.mozilla.javascript.gen.c1.exec(D:\Data\Archive\Rhino-15R41\experiments\sample.js) at org.mozilla.javascript.Context.evaluateReader(Context.java:979) The exception above is thrown by Rhino 1.5R5 Release Candidate 1. Thanks in advance, Ishak Mesut Igor Bukanov To mesuti@aciworldwide.com 02/25/2004 PM cc 04:54 Subject Re: org.mozilla.javascript.EvaluatorExc eption: Can't convert to type 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 > .