XStream
  1. XStream
  2. XSTR-358

@XStreamConverter annotation does not properly initialize the converter class

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.1
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      Sun 1.5

      Description

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

        People

        • Assignee:
          Unassigned
          Reporter:
          Steve Tynor
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: