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: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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 ...

Reply via email to