On Mon, 2005-03-28 at 10:49, Thomas DeWeese wrote:
> Hi Engineering,
>
> This looks to really be a bug in Rhino. Here is another attempt
> that might work around the problem:
>
I couldn't compile with this patch (I could only find
setCachingEnabled() in ClassCache) but I tried Rhino 1.6R1 with the
previous patch and got no exceptions. I'll try it with the unpatched
RhinoInterpreter.java after lunch.
Thanks,
Stan Dickerson
> Index: sources/org/apache/batik/script/rhino/RhinoInterpreter.java
> ===================================================================
> RCS file:
> /home/cvs/xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreter.java,v
> retrieving revision 1.40
> diff -w -u -r1.40 RhinoInterpreter.java
> --- sources/org/apache/batik/script/rhino/RhinoInterpreter.java 27 Mar
> 2005 08:58:35 -0000 1.40
> +++ sources/org/apache/batik/script/rhino/RhinoInterpreter.java 28 Mar
> 2005 15:46:50 -0000
> @@ -38,6 +38,7 @@
> import org.apache.batik.script.Window;
> import org.mozilla.javascript.Context;
> import org.mozilla.javascript.Function;
> +import org.mozilla.javascript.FunctionObject;
> import org.mozilla.javascript.JavaScriptException;
> import org.mozilla.javascript.NativeJavaPackage;
> import org.mozilla.javascript.PropertyException;
> @@ -186,6 +187,12 @@
> ctx.setWrapFactory(wrapFactory);
> ctx.setSecurityController(securityController);
> ctx.setClassShutter(new RhinoClassShutter());
> +
> + // No class loader so don't try and optmize.
> + if (rhinoClassLoader == null) {
> + ctx.setOptimizationLevel(-1);
> + FunctionObject.setCachingEnabled(false);
> + }
> }
> ctx = Context.enter(ctx);
>
> @@ -352,11 +359,16 @@
> }
>
> /**
> - * For <code>RhinoInterpreter</code> this method does nothing.
> + * For <code>RhinoInterpreter</code> this method flushes the
> + * Rhino caches to avoid memory leaks.
> */
> public void dispose() {
> Context.setCachingEnabled(false);
> Context.setCachingEnabled(true);
> +
> + // Don't turn on function caching as this needs a class loader.
> + if (rhinoClassLoader == null)
> + FunctionObject.setCachingEnabled(false);
> }
>
> /**
>
>
>
> engineering wrote:
> > On Thu, 2005-03-24 at 20:14, Thomas DeWeese wrote:
> >
> >>Hi Stan,
> >>
> >> Can you try the attached patch and let me know if this fixes
> >>your problem (you should be able to keep the optimizer directory
> >>with this).
> >>
> >>----
> >
> >
> > Thanks for the response. I tried the patch with batik-src-05-03-06
> > (RhinoInterpreter.java sum = "06257 22" on Linux).
> >
> > I got the following errors (with "optimizer" directory):
> >
> > java.security.AccessControlException: access denied
> > (java.lang.RuntimePermission createClassLoader)
> > at
> > java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
> > at
> > java.security.AccessController.checkPermission(AccessController.java:427)
> > at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
> > at
> > java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:594)
> > at java.lang.ClassLoader.<init>(ClassLoader.java:225)
> > at
> > org.mozilla.javascript.DefiningClassLoader.<init>(DefiningClassLoader.java:55)
> > at org.mozilla.javascript.Context.createClassLoader(Context.java:1837)
> > at
> > org.mozilla.javascript.optimizer.InvokerImpl.createInvoker(InvokerImpl.java:62)
> > at
> > org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:495)
> > at
> > org.mozilla.javascript.FunctionObject.callVarargs(FunctionObject.java:513)
> > at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:378)
> > at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191)
> > at
> > org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java:1573)
> > at org.apache.batik.script.rhino.RhinoInterpreter.<init>(Unknown
> > Source)
> > at
> > org.apache.batik.script.rhino.RhinoInterpreterFactory.createInterpreter(Unknown
> > Source)
> > at org.apache.batik.script.InterpreterPool.createInterpreter(Unknown
> > Source)
> > at org.apache.batik.bridge.BridgeContext.getInterpreter(Unknown Source)
> > at
> > org.apache.batik.bridge.BaseScriptingEnvironment.getInterpreter(Unknown
> > Source)
> > at org.apache.batik.bridge.BaseScriptingEnvironment.loadScripts(Unknown
> > Source)
> > at org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent(Unknown
> > Source)
> > at org.apache.batik.swing.svg.SVGLoadEventDispatcher.run(Unknown
> > Source)
> > java.lang.NullPointerException
> > at
> > org.mozilla.javascript.optimizer.InvokerImpl.createInvoker(InvokerImpl.java:277)
> > at
> > org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:495)
> > at
> > org.mozilla.javascript.FunctionObject.callVarargs(FunctionObject.java:513)
> > at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:378)
> > at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191)
> > at
> > org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java:1573)
> > at org.apache.batik.script.rhino.RhinoInterpreter.<init>(Unknown
> > Source)
> > at
> > org.apache.batik.script.rhino.RhinoInterpreterFactory.createInterpreter(Unknown
> > Source)
> > at org.apache.batik.script.InterpreterPool.createInterpreter(Unknown
> > Source)
> > at org.apache.batik.bridge.BridgeContext.getInterpreter(Unknown Source)
> > at
> > org.apache.batik.bridge.BaseScriptingEnvironment.getInterpreter(Unknown
> > Source)
> > at org.apache.batik.bridge.BaseScriptingEnvironment.loadScripts(Unknown
> > Source)
> > at org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent(Unknown
> > Source)
> > at org.apache.batik.swing.svg.SVGLoadEventDispatcher.run(Unknown
> > Source)
> >
> > The second exception repeated several times.
> >
> > Thanks.
> >
> >
> >>Index: sources/org/apache/batik/script/rhino/RhinoInterpreter.java
> >>===================================================================
> >>RCS file:
> >>/home/cvs/xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreter.java,v
> >>retrieving revision 1.39
> >>diff -w -u -r1.39 RhinoInterpreter.java
> >>--- sources/org/apache/batik/script/rhino/RhinoInterpreter.java 18 Aug
> >>2004 07:14:57 -0000 1.39
> >>+++ sources/org/apache/batik/script/rhino/RhinoInterpreter.java 25 Mar
> >>2005 01:06:14 -0000
> >>@@ -186,6 +186,10 @@
> >> ctx.setWrapFactory(wrapFactory);
> >> ctx.setSecurityController(securityController);
> >> ctx.setClassShutter(new RhinoClassShutter());
> >>+
> >>+ // No class loader so don't try and optmize.
> >>+ if (rhinoClassLoader == null)
> >>+ ctx.setOptimizationLevel(-1);
> >> }
> >> ctx = Context.enter(ctx);
> >>
> >>
> >>[EMAIL PROTECTED] wrote:
> >>
> >>>DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
> >>>RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
> >>><http://issues.apache.org/bugzilla/show_bug.cgi?id=34168>.
> >>>ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
> >>>INSERTED IN THE BUG DATABASE.
> >>>
> >>>http://issues.apache.org/bugzilla/show_bug.cgi?id=34168
> >>>
> >>> Summary: applet gets AccessControlException if has ecmascript
> >>> and
> >>> js.jar has optimizer directory
> >>> Product: Batik
> >>> Version: 1.5
> >>> Platform: Other
> >>> OS/Version: Linux
> >>> Status: NEW
> >>> Severity: normal
> >>> Priority: P3
> >>> Component: Scripting
> >>> AssignedTo: [email protected]
> >>> ReportedBy: [EMAIL PROTECTED]
> >>>
> >>>
> >>>Using batik-src-05-03-06.zip and loading an svg in a JSVGCanvas in an
> >>>applet on
> >>>the Linux console and the svg includes ecmascript in a separate file (a
> >>>sub-directory of the svg directory), I get:
> >>>
> >>>java.security.AccessControlException: access denied
> >>>(java.lang.RuntimePermission
> >>>createClassLoader)
> >>> at
> >>>java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
> >>> at
> >>> java.security.AccessController.checkPermission(AccessController.java:427)
> >>> at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
> >>> at
> >>> java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:594)
> >>> at java.lang.ClassLoader.<init>(ClassLoader.java:225)
> >>> at
> >>> org.mozilla.javascript.DefiningClassLoader.<init>(DefiningClassLoader.java:55)
> >>> at org.mozilla.javascript.Context.createClassLoader(Context.java:1837)
> >>> at
> >>> org.mozilla.javascript.optimizer.InvokerImpl.createInvoker(InvokerImpl.java:62)
> >>> at
> >>> org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:495)
> >>> at
> >>> org.mozilla.javascript.FunctionObject.callVarargs(FunctionObject.java:513)
> >>> at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:378)
> >>> at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1191)
> >>> at
> >>> org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java:1573)
> >>> at org.apache.batik.script.rhino.RhinoInterpreter.<init>(Unknown Source)
> >>> at
> >>>org.apache.batik.script.rhino.RhinoInterpreterFactory.createInterpreter(Unknown
> >>>Source)
> >>> at org.apache.batik.script.InterpreterPool.createInterpreter(Unknown
> >>> Source)
> >>> at org.apache.batik.bridge.BridgeContext.getInterpreter(Unknown Source)
> >>> at
> >>> org.apache.batik.bridge.BaseScriptingEnvironment.getInterpreter(Unknown
> >>> Source)
> >>> at org.apache.batik.bridge.BaseScriptingEnvironment.loadScripts(Unknown
> >>> Source)
> >>> at org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent(Unknown
> >>> Source)
> >>> at org.apache.batik.swing.svg.SVGLoadEventDispatcher.run(Unknown Source)
> >>>
> >>>
> >>>If I strip the "optimizer" directory from "js.jar", the applet loads and
> >>>the
> >>>ecmascript works but I have the following problem:
> >>>
> >>>
> >>>
> >>>>>Batik 1.5.1
> >>>>>JSVGCanvas in Java applet
> >>>>>setURI(url.toString()) called from init() is OK in all cases
> >>>>>
> >>>>>setURI(url.toString()) called from UserAgent openLink() is:
> >>>>> OK from Windows I.E. or Firefox with "http:" URL
> >>>>> OK on Linux console if a "file:" URL is used to load the
> >>>
> >>>applet
> >>>
> >>>
> >>>>> HANGS on Linux console if an "http:" URL is used to load the
> >>>>> applet (Mozilla or Firefox, Java 1.4.2 or Java 1.5.0)
> >>>>>
> >>>
> >>>
> >>>>...I noticed that when this problem occurs, the last entry in
> >>>>/var/log/httpd/access_log is "...GET
> >>>>/java/org/mozilla/javascript/optimizer/InvokerImpl.class..." so I tried
> >>>>js.jar WITH the optimizer directory (not stripped as discussed in a
> >>>>thread last fall). I got a security exception as expected but setURI()
> >>>>succeeded.
> >>>
> >>>
> >>>These threads discuss the problem:
> >>>
> >>>http://mail-archives.eu.apache.org/mod_mbox/xmlgraphics-batik-users/200410.mbox/[EMAIL
> >>> PROTECTED]
> >>>
> >>>http://mail-archives.eu.apache.org/mod_mbox/xmlgraphics-batik-users/200501.mbox/[EMAIL
> >>> PROTECTED]
> >>>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Stan Dickerson
Product Development Engineer
Energy Control Systems
2940 Cole Court
Norcross, GA 30071
1-800-648-0970
770-448-0651
770-446-1319 fax
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]