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

Key: XSTR-358
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Steve Tynor
Votes: 0
Watchers: 1
Operations

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

@XStreamConverter annotation does not properly initialize the converter class

Created: 26/Oct/06 05:14 PM   Updated: 09/Nov/06 04:58 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2.1

JDK version and platform: Sun 1.5


 Description  « Hide
I have converters that require intitialization via their constructors (common functionality in an AbstractConverter and text like:

public class MatrixIdConverter extends AbstractMapConverter {
public MatrixIdConverter() {
super("matrix id", ServiceLocator.getMapManager().getMatrixNameMap());
}
}


the problem is that such a converter invoked via an @XStreamConverter(MatrixIdConverter.class) annotation does not work -- due to using Sun14ReflectionProvider to instantiate the converter object (AnnotationReflectionConverter.java at about line 35):

protected void marshallField(final MarshallingContext context,
Object newObj, Field field) {
XStreamConverter annotation = annotationProvider.getAnnotation(field, XStreamConverter.class);
if (annotation != null) {
context.convertAnother(newObj, (Converter) reflectionProvider
.newInstance(annotation.value()));
} else {
context.convertAnother(newObj);
}
}

Just because I want to use the non-constructor serialization for my XML serialization does not mean I want to avoid constructors for my converters. Is there a way to avoid this? (I.e. I would think that the code should always use pure Java reflection for instantiating "worker" objects and only use Sun14 style reflection for instantiating deserialized objects.)



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Guilherme Silveira - 07/Nov/06 04:53 AM
revision 1042 uses java usual reflection

Joerg Schaible - 09/Nov/06 04:58 PM
Closing as fixed for 1.2.1