Hello Once Again, Thanks for responding David. Like you said I declared the streams that threw the Serialization Exception as transient, but now it's throwing me a "java.lang.StackOverflowError" . I tried increasing the size of the JVM by using -Xmx parameter but even then the actual size of the file written remained the same...so I guess that it's not something that just increasing the JVM size will help.
However the file written to writes upto a particular size( in my case 3,189kb) and gives the Exception.
java.lang.StackOverflowError at sun.misc.SoftCache.get(SoftCache.java:269) at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:238) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1010) at java.io.ObjectOutputStream.defaultWriteFields (ObjectOutputStream.java:1330) at java.io.ObjectOutputStream.writeSerialData (ObjectOutputStream.java:1302) at java.io.ObjectOutputStream.writeOrdinaryObject (ObjectOutputStream.java:1245) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
sorry for that .. the code posted above was my interpretation of what Stuart Gray meant.I was just trying to clarify it.
the actual code that i am working on is a legacy piece of C/C++ code that had been ported to java some years ago .It's actually responsible for conversions from English to the local Languages of my region.There are 2 stages to the conversion.
the first is where the rule files, the dictionay files etc(which are basically flat files) are read into instances of my own classes which are loaded by the Converter class.
the second stage is when i actually convert data using the Converter class which now has access to the above rules.
I've been trying to serialize my object after the first stage.
The problem is when i try to Serialize the object some of the flat files are read but the large flat files that contain the actual rules are copied to a certain extend before the "STACK OVERFLOW EXCEPTION" pops up.
I've made sure that there is no circular depenencies. ----------------------------------- The link below is of a similar post so i was hoping that is a generic problem with large objects which need to be serialized
Well, recursive references can be a lot more subtle than your example; I was thinking more of recursive field references than constructor calls. (e.g: A.field refers to B, and B.anotherfield refers to A).