You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2003/02/06 16:23:34 UTC
DO NOT REPLY [Bug 16844] New: -
MapDeserializer creates only HashMaps, throwing ClassCastException when assigning
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16844>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16844
MapDeserializer creates only HashMaps, throwing ClassCastException when assigning
Summary: MapDeserializer creates only HashMaps, throwing
ClassCastException when assigning
Product: Axis
Version: 1.0
Platform: All
OS/Version: All
Status: NEW
Severity: Major
Priority: Other
Component: Serialization/Deserialization
AssignedTo: axis-dev@ws.apache.org
ReportedBy: jlerner@genome.wi.mit.edu
The org.apache.axis.encoding.ser.MapDeserializer creates a HashMap object,
regardless of the type of the original serialized Map. When it attempts to set
the actual entity, it then throws a ClassCastException.
Proposal: add a classname attribute in MapSerializer.serialize that provides the
actual classname to the deserializer, then instantiate that class by name
instead of hardwiring with a HashMap. Something like:
serialize:
((org.xml.sax.helpers.AttributesImpl)attributes).addAttribute(someURI, "class",
"xsi:class", "CDATA", value.getClass().getName());
deserialize:
try {
String className = attributes.getValue("xsi:class");
Class clsMap = Class.forName(className);
Map map = clsMap.newInstance();
} catch ClassNotFoundException, LinkageError, ExceptionInInitializerError,
InstantiationException, IllegalAccessException, SecurityException ...