From 81543cd446fdd20c0c1771a4b6cbb3deda33a59d Mon Sep 17 00:00:00 2001 From: "nboyd%atg.com" Date: Fri, 18 May 2001 15:31:49 +0000 Subject: [PATCH] Fix problem in the following mail: Subject: Embedding Rhino in an Applet Resent-Date: Thu, 17 May 2001 14:53:05 -0700 (PDT) Resent-From: mozilla-jseng@mozilla.org Date: Thu, 17 May 2001 16:39:14 -0700 From: "Chester Kustarz II" Organization: monkey.org To: mozilla-jseng@mozilla.org Newsgroups: netscape.public.mozilla.jseng Hello, I am trying to find a scripting language with an interpreter that I can embed in an applet in order to run test scripts inside the applet. I have already tried TCL-based Jacl and they do not support running inside an applet. I then downloaded the Rhino/JS interpreter but am having trouble getting it to run inside the browser (IE 5.5). Here is the exception I am getting: com.ms.security.SecurityExceptionEx[org/mozilla/javascript/ScriptRuntime.]: Reflective access to class java.lang.Thread prohibited. at com/ms/security/permissions/ReflectionPermission.check at com/ms/security/PolicyEngine.deepCheck at com/ms/security/PolicyEngine.checkPermission at com/ms/security/StandardSecurityManager.chk at com/ms/security/StandardSecurityManager.checkMemberAccess at java/lang/Class.checkMemberAccess at java/lang/Class.getDeclaredMethod at org/mozilla/javascript/ScriptRuntime. at org/mozilla/javascript/ScriptableObject.getExclusionList at org/mozilla/javascript/ScriptableObject.defineClass at org/mozilla/javascript/Context.initStandardObjects at org/mozilla/javascript/Context.initStandardObjects at RhinoShellApplet.init at com/ms/applet/AppletPanel.securedCall0 at com/ms/applet/AppletPanel.securedCall at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.run at java/lang/Thread.run com.ms.security.SecurityExceptionEx[org/mozilla/javascript/Context.initStand ardObjects]: Unable to access system property: org.mozilla.javascript.JavaAdapter at com/ms/security/permissions/PropertyPermission.check at com/ms/security/PolicyEngine.shallowCheck at com/ms/security/PolicyEngine.checkCallersPermission at com/ms/security/StandardSecurityManager.chk at com/ms/security/StandardSecurityManager.checkPropertyAccess at java/lang/System.getProperty at org/mozilla/javascript/Context.initStandardObjects at org/mozilla/javascript/Context.initStandardObjects at RhinoShellApplet.init at com/ms/applet/AppletPanel.securedCall0 at com/ms/applet/AppletPanel.securedCall at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.run at java/lang/Thread.run --- js/rhino/src/org/mozilla/javascript/ScriptRuntime.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java index 5f88cafea756..5f1f502a196b 100644 --- a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java +++ b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java @@ -2024,11 +2024,17 @@ public class ScriptRuntime { private static Method getContextClassLoaderMethod; static { try { + // Don't use "Thread.class": that performs the lookup + // in the class initializer, which doesn't allow us to + // catch possible security exceptions. + Class threadClass = Class.forName("java.lang.Thread"); // We'd like to use "getContextClassLoader", but // that's only available on Java2. getContextClassLoaderMethod = - Thread.class.getDeclaredMethod("getContextClassLoader", + threadClass.getDeclaredMethod("getContextClassLoader", new Class[0]); + } catch (ClassNotFoundException e) { + // ignore exceptions; we'll use Class.forName instead. } catch (NoSuchMethodException e) { // ignore exceptions; we'll use Class.forName instead. } catch (SecurityException e) {