Support for readResolve()

at 2006-05-03 in EASC by friebe (0 comments)

The EASC's Java deserializer now supports correctly objects that have a readResolve() method. See Java Object Serialization Specification: 3.7 The readResolve Method for details.

Here's an example of a Java class with readResolve:

public class EMailAddress {
protected String data;
private final transient String localpart;
private final transient String domain;

public EMailAddress(String localpart, String domain) {
this.localpart= localpart;
this.domain= domain;
}

protected Object readResolve() throws java.io.ObjectStreamException {
int pos= this.data.indexOf('@');
return new EMailAddress(
this.data.substring(0, pos),
this.data.substring(pos+ 1, this.data.length())
);
}
}

On the wire, only the data member is transmitted (because localpart and domainname are transient). In this case, we must first create an instance of this class, set the data member, and then call its readResolve() method, replacing the instance with the method's return value.



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases

Related

Find related articles by a search for «Support».