Forums Register Login

Doubt in StackOverflowError

+Pie Number of slices to send: Send
hi,
I am getting error as follows :
I am showing a part of it.
My program is
The error is coming in the "out.writeObject(objClone);"
Can give any idea about the error. My objClone is a object of a class.
+Pie Number of slices to send: Send
No, I don't think that is the location of the error. Something is duplicating itself; it might be to do with the cloning.
You need to go up and down the stack trace and see what you can find.
+Pie Number of slices to send: Send
Can you show us the class definition (without methods, just the fields) of objClone? Because it does seem to be related to that class, and how it is serialized. Also include any methods regarding serializing: readObject, writeObject, etc.
+Pie Number of slices to send: Send
hello Ritchie,
I am not getting your explanation. Now I am sending the function.


My Ooutput is



thanks Abhijit
[ September 17, 2008: Message edited by: Rob Prime ]
+Pie Number of slices to send: Send
Hello Prime,

I just send the class whose object is being passed in the function when I called the given function[public static Object deepClone(Object objClone)]. That is, objClone is the object of TemplateComponent. The function is given in last post.The class with fields only is
+Pie Number of slices to send: Send
So that's two Rectangles and one int. The rest is either static or transient and therefore will not be serialized.

However, this class is abstract, and it cannot be instantiated. The actual class, and any class between the actual class and TemplateComponent, may also add fields. Perhaps some of those are causing the problem.
+Pie Number of slices to send: Send
Right, I've been diving into the Java code (with thanks to JAD), and I just can't see why you are getting this error.

A StackOverflowError is thrown when using a recursive method in over 90% of the cases. However, neither sun.misc.SoftCache#get nor sun.misc.SoftCache#processQueue is recursive. processQueue does have a loop, but that shouldn't throw that error. It does call some methods of a ReferenceQueue (poll) and a SoftReference sub class, but that too should not cause this error.


To be frank, I'm quite puzzled.
+Pie Number of slices to send: Send
Hello Prime,
The object 'TemplateComponent' is obtained from other getter method of a class.
The problem is that 'StackOverflowError' is not coming for simple senerio.For the complex case only the error is occuring.

Ok, thanks for replying.....
Yes, it is little bit confusing by showing a bit of code here only. Because there are lots of intermediate classes in the applicaation.

+Pie Number of slices to send: Send
hello

hi,

Through out the serialization, there are four classes having different class instance variables in the hierarchical order. There are some non-static and non-transient variables in the classes. So, I make transient for them . Now i am get the proper output.

I like to know that is there any other impact in my application by declaring the variable as transient?

AS I solved the problem by using this, now is it will reflect for other cases too? Because I am using a big application , I do not know any problem of declaring the variables as transient type.
As far my knowledge , the transient will be used for not to serialized the variable.

thank Prime for the suggestion.


Thanks
abhijit
+Pie Number of slices to send: Send
 

Originally posted by Abhijit Das:
I like to know that is there any other impact in my application by declaring the variable as transient?


Well, the value will get a default value (null for objects) if you deserialize it again. You can reinitialize it using the readObject method, or when you need it:


As far my knowledge , the transient will be used for not to serialized the variable.


Correct, that's the only use for transient.
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1560 times.
Similar Threads
java.io. NotSerializableException: java.awt.TexturePaint
class not found exception in applet servlet communication
Does the order of stream closing matters?
Testing serialization performance
Serialization issue
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:34:00.