Subj : Re: java.io.NotSerializableException: org.mozilla.javascript.ClassCache (somewhat long) To : netscape.public.mozilla.jseng From : Attila Szegedi Date : Thu Mar 10 2005 06:56 pm First, ClassCache is not meant to be serialized - I don't think this will change. Now normally, you pass your top level scope to the ScriptableOutputStream constructor, hence it will be stubbed in the stream instead of being written out. ClassCache is set as an associated value of the top level scope, and top level scope being stubbed out, serialization should never reach the ClassCache through it either. So, either you: a) have another path of references that reaches ClassCache (highly unlikely) b) have an object that was serving as a top level scope previously, and you accessed Java objects (hence triggered ClassCache cretion) from code using it as a top level scope or (not too likely) c) are not specifying your top level scope as the argument to ScriptableOutputStream constructor (likely). -- home: http://www.szegedi.org weblog: http://www.jroller.com/page/aszegedi Visit Szegedi Butterfly fractals at: http://www.szegedi.org/fractals/butterfly/index.html Attila. On 9 Mar 2005 17:15:07 -0800, Andrei Tchijov wrote: > If some one can take a look into this problem, I will appreciate it > greately. > > I am trying to serialize simple JS Function. I do not think it have > much relevance, but function I am trying to serialize looks like this: > > function () { > this.result = this.a + this.b; > return this.result; > } > > This is a snipet of the code which I am using to serialize it. At this > moment function in question stored in remote_method variable: > ... > Scriptable remote_method = ...; > ... > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > > ScriptableOutputStream sos = new ScriptableOutputStream( baos, scope > ); > sos.writeObject( remote_method ); > sos.close(); > ... > > This is what I am getting in return: > > java.io.NotSerializableException: org.mozilla.javascript.ClassCache > at .... .