1 2 Previous Next 17 Replies Latest reply on Jul 18, 2007 4:37 AM by alesj Go to original post
      • 15. Re: ClassInfo being serializable

         

        "alesj" wrote:
        "adrian@jboss.org" wrote:

        But you'll probably need to introduce a Reflection* subclass for
        each to make the serialization work,

        I did a quick change - moved readResolve() from ClassInfoImpl to ReflectClassInfoImpl.
        How come all the tests still work?
        Not covering all the corner cases?


        When I said you need to post in the forums, I meant with proposed solutions,
        not for me to do your work for you. ;-)

        If I make those changes and add extra System.out.printlns to the before
        and after object of serialization, I get the following output:

        139 DEBUG [IntrospectionArrayUnitTestCase] Type: class [Lorg.jboss.test.classinfo.support.ClassInfoAnnotationClass;
        BEFORE ======> ArrayInfoImpl@17653ae{name=[Lorg.jboss.test.classinfo.support.ClassInfoAnnotationClass;}
        AFTER ======> ArrayInfoImpl@134f69a{name=[Lorg.jboss.test.classinfo.support.ClassInfoAnnotationClass;}
        


        So these are not the same object. i.e. no ReadResolve

        You should really be asserting that you get the same object back.
        Also these tests are inadequete. You are only testing the ClassInfo parts
        of the serialized objects.
        Each test must serialize and deserialize its own object and test ALL its fields.
        e.g. does the array have the correct component type, etc. Has it been
        readResolved properly?


        "adrian@jboss.org" wrote:

        i.e. add readResolve() into the introspection factory.

        What about if I add a super class for all Reflection* subclases with readResolve there?


        How can that can work?

        ReflectArrayInfo extends ArrayInfoImpl, AbstractReflectClassInfo
        is not valid java, it's multiple inheritance.

        • 16. Re: ClassInfo being serializable

           


          You should really be asserting that you get the same object back.
          Also these tests are inadequete. You are only testing the ClassInfo parts
          of the serialized objects.
          Each test must serialize and deserialize its own object and test ALL its fields.
          e.g. does the array have the correct component type, etc. Has it been
          readResolved properly?


          Well actually if you test they are the same object then it is really redundant
          to test all fields. The same object can't have different values to the original. :-)


          • 17. Re: ClassInfo being serializable
            alesj

             

            "adrian@jboss.org" wrote:

            Well actually if you test they are the same object then it is really redundant
            to test all fields. The same object can't have different values to the original. :-)

            I've changed the assertion to be assertTrue on == after deserialization.

            I've exposed delegate in IntrospectionTypeInfoFactory for package protected, so that it can be used by ReflectClassInfoImpl in its readResolve method - not creating new instances of TypeInfoFactory on every readResolve invocation.

            Did the same for JavassistTypeInfoFactory for similarity/consistency with Introspection model.

            I left the SerializableHelper in ClassInfoImpl - with providing static TypeInfoFactory instance from new Configuration.

            1 2 Previous Next