Return-Path: Delivered-To: apmail-xml-batik-dev-archive@xml.apache.org Received: (qmail 64322 invoked by uid 500); 6 Jun 2002 08:33:48 -0000 Mailing-List: contact batik-dev-help@xml.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: batik-dev@xml.apache.org Delivered-To: mailing list batik-dev@xml.apache.org Received: (qmail 64308 invoked by uid 500); 6 Jun 2002 08:33:47 -0000 Delivered-To: apmail-xml-batik-cvs@apache.org Date: 6 Jun 2002 08:33:46 -0000 Message-ID: <20020606083346.11928.qmail@icarus.apache.org> From: vhardy@apache.org To: xml-batik-cvs@apache.org Subject: cvs commit: xml-batik/sources/org/apache/batik/script/rhino RhinoInterpreter.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vhardy 2002/06/06 01:33:46 Modified: sources/org/apache/batik/script/rhino RhinoInterpreter.java Log: Fixed problem showed by ..../script/rhino/eval.svg Revision Changes Path 1.18 +20 -11 xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreter.java Index: RhinoInterpreter.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreter.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- RhinoInterpreter.java 14 May 2002 08:57:32 -0000 1.17 +++ RhinoInterpreter.java 6 Jun 2002 08:33:46 -0000 1.18 @@ -15,7 +15,9 @@ import java.net.URL; +import java.security.AccessController; import java.security.AccessControlContext; +import java.security.PrivilegedAction; import java.util.Iterator; import java.util.LinkedList; @@ -44,7 +46,7 @@ * A simple implementation of Interpreter interface to use * Rhino ECMAScript interpreter. * @author Christophe Jolif - * @version $Id: RhinoInterpreter.java,v 1.17 2002/05/14 08:57:32 vhardy Exp $ + * @version $Id: RhinoInterpreter.java,v 1.18 2002/06/06 08:33:46 vhardy Exp $ */ public class RhinoInterpreter implements Interpreter { private static String[] TO_BE_IMPORTED = { @@ -224,10 +226,10 @@ * @return if no exception is thrown during the call, should return the * value of the last expression evaluated in the script. */ - public Object evaluate(String scriptstr) + public Object evaluate(final String scriptstr) throws InterpreterException { - Context ctx = enterContext(); + final Context ctx = enterContext(); ctx.setWrapHandler(wrapHandler); Script script = null; @@ -250,14 +252,21 @@ // this script has not been compiled yet or has been fogotten // since the compilation: // compile it and store it for future use. - try { - script = ctx.compileReader(globalObject, - new StringReader(scriptstr), - "", - 1, rhinoClassLoader); - } catch (IOException io) { - // can't happen because we use a String... - } + + script = (Script)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + try { + return ctx.compileReader(globalObject, + new StringReader(scriptstr), + "", + 1, rhinoClassLoader); + } catch(IOException io) { + // Should never happen: we are using a string + throw new Error(); + } + } + }); + if (compiledScripts.size()+1 > MAX_CACHED_SCRIPTS) { // too many cached items - we should delete the oldest entry. // all of this is very fast on linkedlist --------------------------------------------------------------------- To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org For additional commands, e-mail: batik-dev-help@xml.apache.org