Closed
Bug 255595
Opened 20 years ago
Closed 19 years ago
Factory class for Context creation
Categories
(Rhino Graveyard :: Core, enhancement)
Tracking
(Not tracked)
RESOLVED
FIXED
1.6R1
People
(Reporter: igor, Assigned: igor)
Details
Attachments
(2 files)
10.58 KB,
patch
|
Details | Diff | Splinter Review | |
1.33 KB,
patch
|
Details | Diff | Splinter Review |
Problem: To setup instruction counting or to override Context.FEATURE_* Rhino embedding should subclass Context and then pass it explicitly to Context.enter to associate it with the current thread. Unfortunately it does not work with JavaAdapter which calls Context.enter() in response to Java calls. If there is no Context instance associated with current thread, that would trigger use of default Context ignoring application wish for customization. Solution: A factory class that can be provided to Rhino runtime which will be used for Context creation.
Assignee | ||
Comment 1•20 years ago
|
||
The initial implementation of factory API in the form of http://lxr.mozilla.org/mozilla/source/js/rhino/src/org/mozilla/javascript/ContextFactory.java was committed during spring 2004. The implementation not only allows for full customization of Context instances but also provide a way to run several independent Rhino run times in one JVM.
Assignee | ||
Comment 2•20 years ago
|
||
The current implementation of ContextFactory introduced a couple of compatibility problems: 1. It started to require that when calling ScriptableObject.callMethod() a Context instance should be associated with the current thread. This is was done not to worry about picking up proper ClassFactory. 2. JavaAdapter also started to require to have active context during adapter creation. This was done to select proper ContextFactory during calls to script methods. This does not matter for ordinary adapter case since it is always called from a running script, but automatic function to Java interface can be called without it. To solve this compatibility issues patch stores ContextFactory in the top scope when Context.initStandardObjects is called. In this way the factory is always reachable from function scope without the need to have active Context instance.
Assignee | ||
Comment 3•20 years ago
|
||
I committed the fix but I will keep the bug assigned if more compatibility issues will pop up.
Status: NEW → ASSIGNED
Target Milestone: --- → 1.5R6
Assignee | ||
Comment 4•20 years ago
|
||
The previous patch introduces nasty regression reported by Merten.Schumann:
> This simple stuff
>
> public static void main(String args[]) throws Exception
> {
> Context cx=Context.enter();
> cx.initStandardObjects(null);
> }
>
> worked in former releases IMHO, now it throws
>
> java.lang.IllegalArgumentException
> at
> org.mozilla.javascript.ScriptableObject.associateValue(ScriptableObject.
> java:1574)
> at
> org.mozilla.javascript.ScriptRuntime.initStandardObjects(ScriptRuntime.j
> ava:127)
> at org.mozilla.javascript.Context.initStandardObjects(Context.java:1108)
> at org.mozilla.javascript.Context.initStandardObjects(Context.java:1075)
> at de.rochade.srap.test.Snippet.main(Snippet.java:14) Exception in
> thread "main"
The fix fixes that.
Assignee | ||
Comment 5•20 years ago
|
||
The last fix is in CVS. The bug realy should stay open for some time.
Assignee | ||
Comment 6•19 years ago
|
||
Done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•