Subj : Rhino problem with overloaded functions To : netscape.public.mozilla.jseng From : mesuti@aciworldwide.com Date : Thu Feb 26 2004 12:06 pm Hi, Thank you very much Igor. With your help is my previous problem is solved. I've now the following problem (the last one I home). I've a host object which contains two toString() methods (e.g. toString() and toString(Integer encoding)). My JavaScript calls the "toString(Integer enc)" but Rhino calls always the last one. The code of Host object looks likes: 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) { } public boolean jsFunction_equals(ByteString bs) { } public String jsFunction_toString(Integer enc) { return new String("test-1"); } public String jsFunction_toString() { return new String("test-2"); } public String getClassName() { return "ByteString"; } } The following JavaScript is executed by Rhino: var tmpA = new ByteString("Ishak ", ASCII); var tmpB = new ByteString("Mesut", ASCII); var tmpC = tmpA.concat(tmpB); var tmpD = tmpC.concat(tmpA); var tmpE = new ByteString("Ishak Mesut", ASCII); if (tmpE.equals(tmpC)) { data.de_boolean_str = "TRUE"; } else { data.de_boolean_str = "FALSE"; } data.de_int = tmpD.length; data.output = tmpD; data.de_str = tmpD.toString(ASCII); //End of Java Script the outcome of data.de_str variable bocomes "test-2" instead of "test-1". The Host Object 'ByteString' and constant integer ASCII is added to the scope as follows: Scriptable jsArgs = cx.toObject(new Integer(Constant.ASCII), scope); scope.put("ASCII", scope, jsArgs); ScriptableObject.defineClass(scope, ByteString.class); Any helps is appreciated, Thanks in advence, Ishak Mesut .