History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-376
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: J. Matthew Pryor
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XStream

AttributeMapper problems with getDeclaredField() and inherieted fields

Created: 09/Jan/07 02:25 AM   Updated: 24/May/07 12:38 AM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2.2

File Attachments: 1. Java Source File Test.java (0.7 kb)


JDK version and platform: windows java 1.5


 Description  « Hide
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) { return (SingleValueConverter)converter; } 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 :



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible - 30/Apr/07 03:42 PM
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.

Joerg Schaible - 11/May/07 07:09 AM
Found another culprit, it should be really fixed now.