Skip to main content

Replace XMLEncoder, Serializable by JSX?

4 replies [Last post]
cowwoc
Offline
Joined: 2003-08-24
Points: 0

Hi,

I know XMLEncoder is a relatively new approach but my recent experience with it has been very troublesome (extremely poor performance, cyptic error messages, etc) and meanwhile I ran into JSX: http://www.csse.monash.edu.au/~bren/JSX/

JSX seems like a mature product that can do pretty impressive stuff. It allows you to encode any class into XML, regardless of whether it is a bean, implements Serializable or anything else. "It just works" is its slogan and it seems to me that if that is true Sun should seriously consider adding it into Mustang.

Serializing classes in J2SE has always been problematic, almost as much as printing in J2SE. It's one of those things that seems to get completely rewritten every second revision.

Can someone from Sun please quickly review JSX (url provided above) and give me your first impressions?

Thank you,
Gili

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
patrikbeno
Offline
Joined: 2004-10-11
Points: 0

looks good but you seem to compare apples and oranges: while XMLEncoder is AFAIK just JavaBean serializer, JSX is object serialization solution.

Just smart library, not something to be added to Java6

cowwoc
Offline
Joined: 2003-08-24
Points: 0

I don't understand.

JSX, being an object serializer solution, is a superset of XMLEncoder. Why would you not want to replace it? Moreover, have you actually *tried* using XMLEncoder? It is a total mess! I think a lot of people simply assume XMLEncoder works nice but never actually tried it for themselves. Try it :)

With JSX, I use 3 lines of code and away I go. Plus, with XMLEncoder, Sun is internally adding PersistenceDelegates to a lot of the core classes so they can be encoded properly. This is a waste of their resources. JSX would automatically persist all objects for them.

Gili

cowwoc
Offline
Joined: 2003-08-24
Points: 0

FYI: I just tried this out fairly quickly and I'm *very* impressed. You can serialize *any* class very easily! Serializing java.util.Random was very easy and it is important to note that it even captured private fields in the serialization!

This is *great* stuff! Ease-of-use is definately a big factor here!

cowwoc
Offline
Joined: 2003-08-24
Points: 0

Ok, I'm really looking for some feedback to this idea now. Here is the code snipplet I used to encode my object:

ObjOut out = new ObjOut(new FileWriter("c:/jsx.xml"));
out.writeObject(this);
out.close();

It is so amazingly simple to use and is backwards compatible with JOS (Java Object Serialization) so ObjOut actually extends ObjectOutputStream and ObjIn actually extends ObjectInputStream. And from personal experience, it is *fast*

What do you guys think?

Gili