I haven't tried it outside the shell (I try to stay in JS-land as much as possible!) but I suspect that's right.
I came up with an awful temporary workaround (specific to my situation, not generic) that I think further confirms this is bug #374918: whenever I call evaluateString I set the first scope's (Rhino shell's scope) String.prototype.isa, Number.prototype.isa, and Boolean.prototype.isa equal to the second scope's (initStandardObjects's scope), then I restore them when it's done. Then strings, numbers, and booleans have the correct "isa" property. On Oct 2, 5:35 am, Marc Guillemot <[EMAIL PROTECTED]> wrote: > Hi, > > if I correctly understand you, it happens only in the Rhino shell, is > that right? I don't know the shell at all, but I can imagine that it is > an other manifestation of bug 374918 as the shell surely initializes a > default scope. > > Cheers, > Marc. > -- > Web:http://www.efficient-webtesting.com > Blog:http://mguillem.wordpress.com > > > > tlrobinson wrote: > > If I set a property on a primitive object's prototype, it doesn't seem > > to be propagated to instanced of that primitive, but *not* in the > > Rhino shell, only if I create a scope with initStandardObjects. Also, > > built in objects that aren't primitives, but actual Objects (like > > Array and Date) work correctly, it's only String, Number, and Boolean. > > > Here's a test case. As you can see, only Array and Date objects > > correctly inherit the "isa" property from their prototypes, even > > though it clearly *is* set on the prototype: > > > print("== Shell scope =="); > > > String.prototype.isa = "ok!"; > > Array.prototype.isa = "ok!"; > > Number.prototype.isa = "ok!"; > > Boolean.prototype.isa = "ok!"; > > Date.prototype.isa = "ok!"; > > > var string = "string"; > > print("string=" + string + ", " + string.isa + " (" + > > String.prototype.isa + ")"); > > var array = [1,2,3]; > > print("array=" + array + ", " + array.isa + " (" + > > Array.prototype.isa + ")"); > > var number = 42; > > print("number=" + number + ", " + number.isa + " (" + > > Number.prototype.isa + ")"); > > var bool = true; > > print("bool=" + bool + ", " + bool.isa + " (" + > > Boolean.prototype.isa + ")"); > > var date = new Date(); > > print("date=" + date + ", " + date.isa + " (" + Date.prototype.isa > > + ")"); > > > cx = Packages.org.mozilla.javascript.Context.enter(); > > scope = cx.initStandardObjects(); > > cx.evaluateString(scope, '\ > > print = function(obj) > > { java.lang.System.out.println(String(obj)); }; \ > > print("== Standard scope =="); \ > > String.prototype.isa = "ok!"; \ > > Array.prototype.isa = "ok!"; \ > > Number.prototype.isa = "ok!"; \ > > Boolean.prototype.isa = "ok!"; \ > > Date.prototype.isa = "ok!"; \ > > var string = "string"; \ > > print("string=" + string + ", " + string.isa + " (" + > > String.prototype.isa + ")"); \ > > var array = [1,2,3]; \ > > print("array=" + array + ", " + array.isa + " (" + > > Array.prototype.isa + ")"); \ > > var number = 42; \ > > print("number=" + number + ", " + number.isa + " (" + > > Number.prototype.isa + ")"); \ > > var bool = true; \ > > print("bool=" + bool + ", " + bool.isa + " (" + > > Boolean.prototype.isa + ")"); \ > > var date = new Date(); \ > > print("date=" + date + ", " + date.isa + " (" + > > Date.prototype.isa + ")");', > > "<cmd>", 1, null); > > > Any idea what's going on? Is this a manifestation of this bug: > >https://bugzilla.mozilla.org/show_bug.cgi?id=374918 > > > We use this technique in Objective-J (http://cappuccino.org) to "toll- > > free bridge" the built in JS objects to their Objective-J > > counterparts, so it would be great if it worked in Rhino (already does > > work, only in the shell) > > > Thanks. _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
