Subj : Sealing Scopes To : netscape.public.mozilla.jseng From : vige46 Date : Thu Oct 07 2004 07:57 am Hi, I'd like to use one top ScriptableObject among several threads as described in http://www.mozilla.org/rhino/scopes.html I'd like to combine it with sealing the top scriptable object:
Context tempContext=Context.enter();
sharedScope=new ImporterTopLevel(tempContext,true);
//BLOCK1: ....some operations:
tempContext.evaluateString(sharedScope,"importPackage(Packages.java.util);",null,0,null);
sharedScope.put("a",sharedScope,new Integer(10));
//seal object then
sharedScope.sealObject();
Context.exit();
In another thread, I'd like to use this sharedScope as a prototype for
another( local) scope:
Context context;
context=Context.enter();
Scriptable scope=new ImporterTopLevel(context,true);
scope.setPrototype(sharedScope);
scope.setParentScope(null);
Everything works fine( I have access to propertie 'a' defined in
BLOCK1), untill I execute JavaScript command, which defines new
property
Object returnValue=context.evaluateString(scope, "var l = new
LinkedList();", null, 0, null);
When calling this, I get org.mozilla.javascript.EvaluatorException:
Cannot remove a property from a sealed object: XML.
Thank you for any help.
I use Rhino 1_6R1pre.
.