I have a script which passes a bunch of javascript-object data into my
java object. It is basically JSON-style data except it includes
functions. At some point after that script evaluates I bind the
javascript data into java, in general using the Context.jsToJava()
function to perform type conversion.

My problem is in the conversion of javascript functions to java
interfaces. When I attempt to do this AFTER the script is evaluated, I
get the following error:

java.lang.IllegalStateException
        at
org.mozilla.javascript.ScriptRuntime.getTopCallScope(ScriptRuntime.java:
2738)
        at
org.mozilla.javascript.InterfaceAdapter.create(InterfaceAdapter.java:
60)
        at
org.mozilla.javascript.NativeJavaObject.coerceTypeImpl(NativeJavaObject.java:
683)
        at org.mozilla.javascript.Context.jsToJava(Context.java:1653)

This works fine if the conversion is done inside the context of script
evaluation, which makes a certain kind of sense - My function must
have a scope in order to run.

However, is there some special way that I can work around this? I can
only really perform data conversion after the script has evaluated.
Can I somehow take my scope + function +context and manufacture a
implementation of a Java interface via the InterfaceAdapter class?

Many thanks!

joel carranza
[EMAIL PROTECTED]
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to