Details
-
Type: Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.2.2
-
Component/s: None
-
Labels:None
-
JDK version and platform:windows java 1.5
Description
AttributeMapper makes use of getDelcaredField() which has very onerous requirements of field visibility and inherited fields.
Personally I find the whole approach taken by the AttributeMapper to be too heavy handed and would like to be able to easily specify that any type that can be handled by a SingleValueConverter should be written/read as an attribute.
Up until the 1.2..2-SNAPSHOT the following approach worked well, I simply added the following MapperWrapper and
class MyAttributeMapper extends MapperWrapper {
XStream xStream;
public MyAttributeMapper(Mapper wrapped, XStream xStream)
{ super(wrapped); this.xStream = xStream; } protected SingleValueConverter getLocalConverterFromItemType(Class type) {
Converter converter = xStream.getConverterLookup().lookupConverterForType(type);
if (converter != null && converter instanceof SingleValueConverter)
else
{ return null; }}
public SingleValueConverter getConverterFromItemType(Class type)
{ return getLocalConverterFromItemType(type); }}
However testing with 1.2.2-SNAPSHOT our entire application bombs because of the added restriction introduced by the use of getDeclaredField() in AttributeMapper, as an example, see the following test :
Matthew, can you test the latest version from the repo? I think I found the culprit. Since we will try to release soon, any report is highly appreciated.