On Mar 4, 11:06 am, howa <[EMAIL PROTECTED]> wrote:
> On 3月4日, 下午11時45分, Norris Boyd <[EMAIL PROTECTED]> wrote:
>
> > On Mar 4, 9:33 am, howa <[EMAIL PROTECTED]> wrote:
>
> > > On 3月4日, 下午10時07分, Norris Boyd <[EMAIL PROTECTED]> wrote:
>
> > > > On Mar 4, 8:44 am, howa <[EMAIL PROTECTED]> wrote:
>
> > > > > On 3月4日, 下午6時48分, Attila Szegedi <[EMAIL PROTECTED]> wrote:
>
> > > > > > Define o as:
>
> > > > > > o = { a: 7, b: function() { return this.a+1; }}
>
> > > > > > Attila.
>
> > > > > > On 2008.03.04., at 7:40, howa wrote:
>
> > > > > > > Sample codes:
>
> > > > > > > /*************************************/
> > > > > > > ScriptEngineManager mgr = new ScriptEngineManager();
> > > > > > > ScriptEngine engine = mgr.getEngineByName("js");
> > > > > > > try {
> > > > > > > engine.eval("o = { a:7, get b() { return this.a+1; }}; k =
> > > > > > > o.b;");
> > > > > > > System.out.println(engine.get("k"));
>
> > > > > > > } catch (Exception e) {
> > > > > > > e.printStackTrace();
> > > > > > > }
> > > > > > > /*************************************/
>
> > > > > > > Error returns:
>
> > > > > > > javax.script.ScriptException:
> > > > > > > sun.org.mozilla.javascript.internal.EvaluatorException: missing :
> > > > > > > after property id (<Unknown source>#1) in <Unknown source> at line
> > > > > > > number 1
> > > > > > > at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown
> > > > > > > Source)
> > > > > > > at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown
> > > > > > > Source)
> > > > > > > at javax.script.AbstractScriptEngine.eval(Unknown Source)
>
> > > > > > > Any idea?
>
> > > > > > > Howard.
>
> > > > > Yes, but I want to know why Getter didn't work when embedded in my
> > > > > Java codes.
>
> > > > > P.S.
>
> > > > > it is okay if I use the js.jar shell,
>
> > > > > e.g.
>
> > > > > java -jar js.jar
>
> > > > > >> load("getter.js");
>
> > > > > This is works as expected.
>
> > > > The version of Rhino used in javax.script is older and does not
> > > > support getters and setters.
>
> > > > --N
>
> > > Yes, but why the js.jar shell came with the rhino work? (I assume they
> > > are using the same engine?)
>
> > > A little bit strange...
>
> > > Howard
>
> > Which version of js.jar are you using? I assume it is 1.6R6 or later
> > as that's when getters were implemented
> > (seehttp://developer.mozilla.org/en/docs/New_in_Rhino_1.6R6#JavaScript_1....).
> > The version in javax.script is earlier.
>
> > --N
>
> I just downloaded from Mozilla yesterday: rhino1_6R7 (ftp://
> ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R7.zip)
>
> I am using the SAME js.jar for shell testing and Java development.
>
> If I run the js.jar using the JS shell, getter is okay.
>
> However, if I include the js.jar as a library for development, and
> read the JavaScript file, getter didn't work.
>
> Howard.
What do you mean "include the js.jar as a library for development"?
What APIs are you using, javax.script, or the Rhino APIs?
--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino