Perfect, thanks!
On Thu, Feb 19, 2009 at 7:24 AM, Attila Szegedi <[email protected]> wrote: > Well, for 1.7R1, I rewrote the Context code to ensure factory field can't be > null, as it complicated program logic in earlier versions. > > The said complicated logic in older (1.6R7 and older) Rhino versions was > actually falling back to using ContextFactory.getGlobal() when the factory > field was null - it allowed null factory fields and was retrieving > ContextFactory.getGlobal() whenever it needed a factory instance. From 1.7R1 > the field is final and can't be assigned null in constructor, which > simplifies the code quite a lot. > > The answer is then: you can safely extend Context even with currently > released versions, with the caveat that it will then always be bound to > ContextFactory.getGlobal() - in 1.7R1 it'll set its factory field to refer > to whatever is the global factory at constructor time, in earlier versions > it'll retrieve the global factory whenever it needs to use it (1.6R7 and > earlier). > > Attila. > > On 2009.02.19., at 16:04, Patrick Lightbody wrote: > >> Attila, >> Thanks for confirming that with me. My code appears to be running fine >> despite having a null factory field. Does Context.exit() and >> Context.enter() get called at some unpredictable point? I'm not >> calling them at all myself and those look like the only methods I'm >> slightly concerned about, since I don't know what they do. >> >> In other words: am I safe to extend Context in the latest released >> version of Rhino, or do you strongly recommend I go with 1.7R2 so that >> I can pass in the factory? >> >> Patrick >> >> On Thu, Feb 19, 2009 at 6:55 AM, Attila Szegedi <[email protected]> >> wrote: >>> >>> On 2009.02.19., at 15:25, Patrick Lightbody wrote: >>> >>>> Because the "factory" field is private and is only set in a >>>> package-protected constructor, and because getFactory() is >>>> public+final, there is no way for me to extend Context while still >>>> passing in a reference to the factory. In the example JavaDocs, this >>>> looks like it's skipped entirely. >>> >>> Yep, others hit that problem too. I promoted the visibility of that >>> constructor to protected for benefit of subclasses in 1.7R2. 1.7R2 is >>> still >>> unreleased, but you can grab a RC at >>> <ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R2-RC1.zip> >>> >>> Hope that helps, >>> Attila. > > > > > _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
