Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

can you call .readObject from readResolve?

Thread view: 
bsd_mike - 05 Oct 2006 14:47 GMT
I have a static integer value in a class that I am trying to serialize.

We have our own writeObject what writes the integer out each time the
object is written.
This works.

However, I would like to only write the integer out once.

I can detect when I am on the last object during a write, but can't
during a read...
except through readResolve.

Would it work to call readObject from readResolve to get that integer?

Other ideas?

-MIke
Thomas Hawtin - 05 Oct 2006 16:56 GMT
> I have a static integer value in a class that I am trying to serialize.
>
[quoted text clipped - 9 lines]
>
> Would it work to call readObject from readResolve to get that integer?

I'm not exactly sure what you are after.

If you are trying to serialise a static field, I think the answer is to
rework your code into something sensible.

If you want a serialised object to stand in for a reference to a
particular static field value, then readResolve seems sensible (I'm not
exactly sure on the rules for static typing on that). I don't know why
you would want to manipulate the stream from readResolve.

Tom Hawtin
Robert Klemme - 05 Oct 2006 20:28 GMT
> I have a static integer value in a class that I am trying to serialize.

There is no point in serializing static data as it will always be there
(always meaning as long as the class is loaded).

> Other ideas?

Change your code to remove the necessity to serialize static content.

Kind regards

    robert


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.