Closed
Bug 37317
Opened 25 years ago
Closed 25 years ago
multithread not working with JavaAdapter
Categories
(Rhino Graveyard :: Core, defect, P3)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: howard, Assigned: norrisboyd)
Details
Attachments
(4 files)
In JS, we implement a Java interface and in Java we call methods of this
interface from a seperate thread and a "No context associated with current
thread" exception is thrown. Note, this only happens when the method has at
least one parameter. If the method has no parameter, it worked fine. I enclosed
several files to illustrate this problem.
Hello.java is the interface declaration file.
SayHello.java is the class that use this interface.
thread.js is the JS file that implements Hello interface and passes the
interface to SayHello class.
awt.js is a similar JS file which implements actionListener interface and
passes the interface to Button class. This JS file worked fine.
To repeat this problem, compile both java files and put the classes in the same
directory as that contains js.jar and jstools.jar, run the following command
from the DOS command:
java -classpath .;js.jar;jstools.jar org.mozilla.javascript.tools.shell.Main
At JS prompt, type "load thread.js", you will get the following exception:
js> load("thread.js");
current Thread is Thread[main,5,main]
js> current Thread is Thread[Thread-0,5,main]
Exception caught No Context associated with current Thread
java.lang.RuntimeException: No Context associated with current Thread
at org.mozilla.javascript.Context.getContext()
at org.mozilla.javascript.ScriptRuntime.toObject()
at org.mozilla.javascript.Context.toObject()
at adapter0.print()
at SayHello$HelloThread.run()
Notes:
1) if the print method in the Hello interface doesn't take any parameters, it
worked fine;
2) awt.js runs fine, even though the actionPerformed method is called on a
seperate thread too. I don't know why.
3) a side problem. importClass can't be used more than once. If I try to
run "load thread.js" again on the same JS session, I got an exception
saying "property already defined". I think it should just return quietly
instead of throwing an exception, just like importPackage does.
4) This problem happened in both JDK1.2 and JDK1.1.8.
Howard
Assignee | ||
Comment 5•25 years ago
|
||
Checked in fix for multithreaded problem:
Checking in JavaAdapter.java;
/m/pub/mozilla/js/rhino/org/mozilla/javascript/JavaAdapter.java,v <-- JavaAdap
ter.java
new revision: 1.23; previous revision: 1.22
done
Status: NEW → ASSIGNED
Summary: multithread not working with JavaAdapter → multithread not working with JavaAdapter
Assignee | ||
Comment 6•25 years ago
|
||
Fix for multiple uses of importClass on the same class:
Checking in ImporterTopLevel.java;
/m/pub/mozilla/js/rhino/org/mozilla/javascript/ImporterTopLevel.java,v <-- Imp
orterTopLevel.java
new revision: 1.9; previous revision: 1.8
done
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•