Closed
Bug 400159
Opened 18 years ago
Closed 17 years ago
Make org.mozilla.javascript.Synchronizer act on native Java objects when available
Categories
(Rhino Graveyard :: Core, enhancement)
Rhino Graveyard
Core
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: irony.delerium, Unassigned)
Details
Attachments
(1 file)
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/419.3 (KHTML, like Gecko) Safari/419.3
Build Identifier: Rhino 1.6r6
Synchronizer acts on JS object (Scriptable) for synchronization; this means using the Java primitives for synchronization (notify, wait, notifyAll) as well when operating in a threaded context is difficult to impossible. Patch included to change Synchronizer so that when a NativeJavaObject is found, it is unwrapped before synchronizing against it.
Reproducible: Always
Steps to Reproduce:
Run the following in the JS shell provided by Rhino:
----
var o = new java.lang.Object();
spawn(function() {
var f = sync(function() {
this.wait();
print("Hello world!");
});
f.apply(o, []);
});
var p = sync(function() {
this.notify();
});
p.apply(o, []);
Actual Results:
Exception in thread "Thread-1" org.mozilla.javascript.WrappedException: Wrapped java.lang.IllegalMonitorStateException: current thread not owner (<stdin>#11)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1757)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:170)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3237)
at script(<stdin>:11)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2394)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at org.mozilla.javascript.Synchronizer.call(Synchronizer.java:78)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2234)
Expected Results:
The script should have printed "Hello world!" to the console.
Reporter | ||
Comment 1•18 years ago
|
||
This changes the target of synchronization in org.mozilla.javascript.Synchronizer from the Scriptable representing "this" in JavaScript to the underlying Java object if one is available.
Comment 2•17 years ago
|
||
Fixed in CVS HEAD:
Checking in src/org/mozilla/javascript/Synchronizer.java;
/cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Synchronizer.java,v <-- Synchronizer.java
new revision: 1.8; previous revision: 1.7
done
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•