5 Replies Latest reply on Aug 31, 2004 4:31 AM by Tomasz Nazar

    Instrumentor makes _transient_ fields when introducing field



      Another separate topic after work at weekend.

      I need my objects to be serialized. I also need to introduce Identificable implementation to every of them, to give them OID. I did this by introducing IdentificableMixin:

      public class IdentificableMixin...
       private Long oid;
       private void setOID(...
       private Long getOID(...

      After logging few lost hours it happened that (by checking decompiled class) JBossAOP introduces this mixin to the class as a field and makes it transient. Decompiled sample:
       private transient IdentificableMixin _my$demo$getOID$IdentificableStringMixin$aop$mixin;

      Unfortunately for me it happend to be _transient_ which doesn't serialize. So my app magically didn't work :/.

      For my app I need mixin fields to be normal - not transient.

      I found 2 places in JBossAOP code which I think are responsible for that:

       private CtField addProtectedField(...
       field.setModifiers(Modifier.PROTECTED | Modifier.TRANSIENT);
       private CtField addPrivateField(....
       field.setModifiers(Modifier.PRIVATE | Modifier.TRANSIENT);

      I've removed Modifier.TRANSIENT, and all the fields (I think) that JBossAOP introduces to classes are not transient.

      So, I did this, but are there any reasons for them to be transient?

      I know that you didn't realized that someone will use Mixins in that way.
      So you see now (or will see in some days :) ).