Hi,

I am running into the same problem described here : 
http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg07308.html.

 

Except I use the @Annotations style. I wrote an example taken from 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=168063

 

I have the following interface :

 

public interface IPersistable extends Serializable {

 

    int getId();

 

    void setId(int id);

 

}

 

And the following aspect :

@Aspect

public class Persistability {

 

    static class Persistable implements IPersistable {

 

        private int id;

 

        public Persistable() {

            super();

        }

 

        public int getId() {

            return id;

        }

 

        public void setId(int id) {

            this.id = id;

        }

 

    }

 

    @DeclareParents(value = "PersistabilityTest", defaultImpl = 
Persistable.class)

    private IPersistable observable;

 

    /**

     *

     * @param bean

     */

    @Pointcut("initialization(IPersistable.new(..)) && this(bean) && 
!this(Persistable)")

    void init(IPersistable bean) {

    }

 

    /**

     * @param bean

     */

    @Before("init(bean)")

    public void beforeInit(IPersistable bean) {

        bean.setId(System.identityHashCode(bean));

    }

 

}

 

And the Test :

public class PersistabilityTest {

 

    @Test

    public void testSerialization() throws Exception {

 

        PersistabilityTest persistabilityTest1 = new PersistabilityTest();

        ByteArrayOutputStream bos = new ByteArrayOutputStream();

        ObjectOutputStream oos = new ObjectOutputStream(bos);

 

        oos.writeObject(persistabilityTest1);

 

        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());

        ObjectInputStream ois = new ObjectInputStream(bis);

 

        PersistabilityTest persistabilityTest2 = (PersistabilityTest) 
ois.readObject();

 

        Assert.assertTrue(persistabilityTest1 instanceof IPersistable);

 

        Assert.assertTrue(persistabilityTest2 instanceof IPersistable);

        System.out.println("persistabilityTest2 is Persistable id=" + 
((IPersistable) persistabilityTest2).getId());

 

        Assert.assertEquals(((IPersistable) persistabilityTest1).getId(), 
((IPersistable) persistabilityTest2).getId());

 

    }

}

 

The test fails at the last line where I expect the id to be equal

 

When I look at the decompiled code for PersistabilityTest, the ITD field 
delegate is transient!!

 

Do I have to file a bug for this issue?

 

Regards

 

Guillaume Lasnier * Technical Architecture Team Leader * SunGard * Asset Arena 
* 147 Bureaux de la Colline, Bâtiment E * 92213 Saint-Cloud CEDEX * France * 
Phone: +33 1 55 39 18 74 * Fax: +33 1 55 39 18 01 * 
http://www.sungard.com/assetarena <http://www.sungard.com/assetarena>   

P Think before you print

 

_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to