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.
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.
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.
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
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.
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.
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.
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.
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.
Post by:autobot
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