This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes java object serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "java object serialization" Watch "java object serialization" New topic
Author

java object serialization

baran tamer
Ranch Hand

Joined: Jan 22, 2009
Posts: 33
Hello,
Is there a trick to serialize an object which doesnt implements serializable interface ?

Something like ISerializationSurrogate in C# maybe ?

Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

Reflection can help you out, but final variables will pose a problem when deserializing.

Perhaps you can use XStream.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
Rob Prime wrote:Reflection can help you


How Reflection helps? Any methods?
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 482
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..


Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
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

Joined: Oct 27, 2005
Posts: 19232

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: java object serialization
 
Similar Threads
generics - why does this work?
MultiDimenaional Array sort
Thread and Object
WA #1.....word association
Array