This is a working example on how to make serialization/deserialization of Rhino continuations when some classes originate from a classloader other than the main application classloader, see mozilla/rhino#1178
The solution depends heavily on how NativeJavaObject class is defined/structured, so it may not work in future versions of Rhino (tested in 1.7.14 only). It looks like a hack but IMO there is no other way to make this use case feasible with the library as is. This is due to how NativeJavaObjects are deserialized: it makes use of the "current" classloader only.
To try it, instantiate ContinuationSerializer (you may need to adjust the constructor signature) and supply your classloader. Then call save (serialize) and restore (deserialize)
It is assumed the parent of such classloader is the classloader that most of application classes belong to. It is also assumed the usual delegation model is followed for loading classes (ie. asking for parents first). Only serializable classes expected.
Note: There is no support for Java adpaters.