Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't serialize object




On Jul 9, 2006, at 9:28 AM, Lou Cohen wrote:

Hello,

After a couple of fruitless days trying to solve this problem, I now turn to
my most trusted resource: this list.


I'm using Java 1.5.0 and Netbeans 5.0. I'm running on Mac OS X 1.4.7, with a
G5 dual processor PPC (1.8GHz.)


I've created a rather complicated object which takes a very long time to
instantiate. My application needs several of these objects, and the wait
time to create them all is unacceptable. I don't understand what the
performance issue is yet, but I thought of this workaround:


Instantiate the object once, and save it to a file as a serialized object.
Then read the object from disk, rather than construct it, as many times as
needed.


I did this for an applet doing Soundex lookups. I serialized some of the data for performance reaons. In one instance I got both size and less
code savings. In another the code I think got a little larger but it should still not need to do the many required initializations.


The applet

http://users.spacestar.net/mikehall/licenses.html

I don't know if this will be time-effective because I'm getting an error
when I try to write the serialized object to disk.

You're trying to serialize Swing, specifically the aqua L&F, which is not serializable as it is. I have successfully serialized my own gui with some slightly involved code. It does tend to be a bit brittle since the code is making no attempt to provide working serialization from release to release. And it still wouldn't do you any good on another platform. Although I hide or substitutes for most of the really un-serializable parts what remains is still OS X specific.
Somewhere in the depths of my to-do list is attempting to come up with a platform neutral mapping API for Swing. This would allow the actual non-serializable L&F to be generated on each platform rather than serialized as is.
Possibly using XStream or some other XML based persistence format.
If you are really serious in trying to serialize some part of the Aqua L&F right now you could contact me off-list and I could provide more details on my serialization tricks and hacks.
Metal I believe is the only L&F that is guaranteed serializable. Although I don't see how you could quite get it to serve the mapping function I'm imagining without visually changing the current components appearance which I think would be pretty disconcerting to the user.



Mike Hall mikehall at spacestar dot net http://www.spacestar.net/users/mikehall http://sourceforge.net/projects/macnative



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

References: 
 >Can't serialize object (From: Lou Cohen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.