views:

276

answers:

1

I've got this piece of Java code with embedded Rhino (irrelevant bits omitted):

Context cx = Context.enter();
Scriptable scope = cx.initStandardObjects();

scope.put("foo", scope, Context.toObject(foo, scope));

ScriptableObject.putProperty(scope, "bar", Context.javaToJS(bar, scope));

where foo extends ScriptableObject and bar is just a POJO without a parent.

Is there, in this particular case, any difference between the way foo and bar are added, or is the result the same?

I tried consulting documentation but I couldn't find any answer. Eventually I just looked up the source code (*rhino1_7R1* version) and my guess is it doesn't really matter in that scenario. Or does it?

+1  A: 

I think you are correct. I believe I've been on the same code-reading expedition as you and reached the same conclusion. The top-level objects of the scope are the same thing as the properties of the scope.

bmargulies