I have create a workaround myself, thank you the same.

In Rhino, the global variable can not be removed, this is the design.
And any global var will be bind to the top Scope, that is the parent's
parent'... scope. If you want to remove it, just set the top scope
empty, and here is the code:

Context context = Context.enter();
Scriptable scope = context.newObject(global);
scope.setPrototype(global);
scope.setParentScope(null);
Context.exit();

is this case, all global var still can not be removed, but now the
scope is current topScope, when you want to romoved all global vars,
you just discard this object and create a new one : )
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to