You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2002/06/06 10:33:46 UTC
cvs commit: xml-batik/sources/org/apache/batik/script/rhino RhinoInterpreter.java
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 <code>Interpreter</code> interface to use
* Rhino ECMAScript interpreter.
* @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
- * @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),
- "<SVG>",
- 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),
+ "<SVG>",
+ 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