Hello,


first of all I'd like to thank you for creating and maintaining XStream. It 
helps us a great deal in most of our unit tests.



We're using XStream 1.4.4 and as we switched from Sun14ReflectionProvider to 
its superclass PureJavaReflectionProvider I noticed breaking tests. After some 
debugging I found out that objects read from XML have properties set, which are 
not part of the XML documents. I took a closer look at those properties and 
realized that they're being initialized on object creation. Nothing special so 
far. So I debugged again with Sun14ReflectionProvider and realized that those 
properties, which should be initialized on object creation, remain null.



Long story short I think the Sun14ReflectionProvider is broken. It does not 
behave the same as its superclass although it should, but only in a more 
efficient way. It does not invoke the public default constructor as expected.



I've provided a unit test and resources to reproduce this behaviour.



Best regards

Enno
import java.io.File;

import org.junit.Assert;
import org.junit.Test;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider;

public class Sun14ReflectionProviderTest {

        @Test
        public void testGetMungedConstructor() throws Exception {
                XStream xStream = new XStream(new Sun14ReflectionProvider()); 
// Seems buggy
                // XStream xStream = new XStream(new 
PureJavaReflectionProvider()); // Works fine
                Something s = (Something) xStream.fromXML(new 
File("Sun14ReflectionProviderTest.testGetMungedConstructor.xml"));
                Assert.assertEquals("Public default constructor invoked", 
s.getFieldX());
        }
}
public class Something {

        private String fieldX = "Field initialized";

        public Something() {
                fieldX = "Public default constructor invoked";
        }

        public String getFieldX() {
                return fieldX;
        }

        public void setFieldX(String fieldX) {
                this.fieldX = fieldX;
        }

}
<Something>
</Something>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to