mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
721391dfa7
contextClassloader problem in ScriptRuntime.java Date: Tue, 11 Apr 2000 09:45:36 -0400 From: "Howard Lin" <howard@softcom.com> To: "Norris Boyd" <norris@netscape.com> CC: "Andrew Wason" <aw@softcom.com> Hi, Norris, we are trying to create a Java class in JavaScript. When security manager is on, everything works fine. But when security manager is off, we got an error saying the "... is not defined". The problem is that in ScriptRuntime.java, when security is on, getContextClassLoader is null due to SecurityException and Class.forName is used to find the class, which works fine. When security is off, ContextClassLoaderMethod is invoked to find the class. Since we use a separate thread to load third party jar files, ContextClassLoaderMethod will throw a ClassNotFound exception. To illustrate this problem, I wrote a simple applet, evaluating a simple js file in its paint method, which is running on a separate thread. When security is off, I got the following: ReferenceError: "Global" is not defined. at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java: 494) at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java, Compile d Code) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java, Compil ed Code) at org.mozilla.javascript.InterpretedScript.call(InterpretedScript.java: 67) at org.mozilla.javascript.InterpretedScript.exec(InterpretedScript.java: 54) at org.mozilla.javascript.Context.evaluateReader(Context.java:739) at test.evaluate(test.java:26) at test.paint(test.java:16) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:117) at java.awt.Component.dispatchEventImpl(Component.java:2447) at java.awt.Container.dispatchEventImpl(Container.java:1035) at java.awt.Component.dispatchEvent(Component.java:2307) at java.awt.EventQueue.dispatchEvent(EventQueue.java:287) at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:10 1) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:92) at java.awt.EventDispatchThread.run(EventDispatchThread.java:83) When security is on, it runs fine. Or if the code moved to init method, it works fine regardless of security. We are using JDK 1.2.2. Howard |
||
---|---|---|
.. | ||
benchmarks | ||
js2 | ||
jsd | ||
jsdj | ||
jsj | ||
macbuild | ||
ref | ||
rhino | ||
semantics | ||
src | ||
tests | ||
.cvsignore | ||
landbranch.pl | ||
Makefile.in | ||
makefile.win |