Error de-serializing a continuation: Can't find top level scope for ClassCache.get

101 views
Skip to first unread message

Michael Bar-sinai

unread,
Apr 27, 2017, 7:47:22 PM4/27/17
to mozilla-rhino
Hello all,

I have a JS script that generates a continuation (by calling a Java function that throws Context.getCurrentContext().captureContinuation()). I then serialize the continuation using ScriptableOutputStream. This works well, as all connected Java objects are serializable.


In some situations, when I de-serialize the stream, I get the error: "Can't find top level scope for ClassCache.get"

This will throw an error:
A = bp.Event("A");
B = bp.Event("B");
C = bp.Event("C");
var r;

bp.registerBThread(function() {
r=bsync({ waitFor : A }); // The problem is with this assignment.
bsync({ waitFor : B });
bsync({ waitFor : C });
});


while this won't (the assignment to r is removed):

/* global bp  */

A = bp.Event("A");
B = bp.Event("B");
C = bp.Event("C");
var r;

bp.registerBThread(function() {
bsync({ waitFor : A }); // The problem is with this assignment.
bsync({ waitFor : B });
bsync({ waitFor : C });
});


Any ideas?
Thanks!

ian

unread,
Apr 29, 2017, 8:13:02 PM4/29/17
to mozilla-rhino
Hi Michael,

Just wondering if you've made any discoveries relating to this. I'm seeing some unexpected behavior around continuations storing the variables declared in global scope (such as `var r` in your example).

Thank you for your time!

Michael Bar-Sinai

unread,
Apr 30, 2017, 1:00:25 AM4/30/17
to mozill...@googlegroups.com
Not yet. I plan to revisit this in the next few days.
Meanwhile, I did find a reliable source code about how to do continuations here:


I'll update once I have something.

-- Michael

--
You received this message because you are subscribed to a topic in the Google Groups "mozilla-rhino" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mozilla-rhino/_FpS27B_01k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mozilla-rhin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Bar-sinai

unread,
May 4, 2017, 5:30:10 AM5/4/17
to mozilla-rhino
Some advancement: This is only happening when a JS variable holds a Java object. That Java object is serializable, though.
Any ideas?


On Sunday, April 30, 2017 at 8:00:25 AM UTC+3, Michael Bar-sinai wrote:
Not yet. I plan to revisit this in the next few days.
Meanwhile, I did find a reliable source code about how to do continuations here:


I'll update once I have something.

-- Michael
To unsubscribe from this group and all its topics, send an email to mozilla-rhino+unsubscribe@googlegroups.com.

CL Yao

unread,
May 30, 2022, 10:46:44 PM5/30/22
to mozilla-rhino
This error too.
I'm using rhino 1.7R4.
This error is because ScriptableObject mark parentScope/prototype as transient. When deserialize it restore slots first and parent/prototype last.
So If a slot ref a NativeJavaObject, It will call ClassCache.get with uninitialized parent scope. Which cause Error.

BTW The last source code in github/master branch seems fixed the problem.

To unsubscribe from this group and all its topics, send an email to mozilla-rhin...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages