• Post Reply Bookmark Topic Watch Topic
  • New Topic

java object serialization  RSS feed

 
baran tamer
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is there a trick to serialize an object which doesnt implements serializable interface ?

Something like ISerializationSurrogate in C# maybe ?

Thanks
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reflection can help you out, but final variables will pose a problem when deserializing.

Perhaps you can use XStream.
 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Reflection can help you


How Reflection helps? Any methods?
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all..

firstly, iam sorry for the basic question..
what is the advantages by using "serialization" by implementing Serializable interface?..
as far as now i just use the Serializable interface for Persistence classes.. (Hibernate)..
but iam still don't know about advantages for Seriablizable interface usage..

What kind of class which has to implemented Serializable interface?..

Thanks in advance..
 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi....Leonardo,

In distributed computing, There is sometimes to requirement to send objects over the wire: To store objects, efficiently,to disk or another medium
and restore them exactly as they were before.

*Because of memory allocation determined by operating system, objects can store in fragements,any whee memory.

*A contiguous stream of bytes required,for storing objects or sending them over the wire.

*Serialization creates a contiguous stream of bytes to represent an object
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
raj chiru wrote:
Rob Prime wrote:Reflection can help you


How Reflection helps? Any methods?

You can retrieve the Fields of a class, and use them to get and set the values of those fields for an object. However, final fields cannot be set using reflection.

Best to use Class.getDeclaredFields() for the current class and all of its super classes, because Class.getFields() only returns public fields.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!