I have a problem wherein I am loading a number of JS files and then executing a function in JavaScript, then I want to wipe the global namespace of the loaded objects, and load a different set of JS files before executing the next JavaScript Function.
Does anyone here know of a good way of doing this without exiting the Rhino JavaScript interpreter.
How exactly you're executing scripts? Some code sample would help.
Some time ago I used it this way:
Object obj = ScriptableObject.getProperty (scope, methodName);
Callable fun = (Callable) obj;
Scriptable thisObj = scope;
scope = ScriptableObject.getTopLevelScope (scope);
Object result = fun.call(cx, scope, thisObj, args);
where scope contains all loaded objects created before and cx is an instance of Context.
So you don't exactly need to wipe anything - just use new scope.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.