2 Replies Latest reply on Aug 12, 2002 3:42 PM by joaocm

    Transient Keyword problem ??

    joaocm

      I'm trying to migrate my application to JBOSS and I found a problem with the transient keyword. I have a class that acts as a Iterator. It have methods like hasNext(), next(), etc... This class is stored in the Web Tier (i.e. Servlet Vector) of my application and is passed to an EJB (Stateful Session Bean) method as an argument. I control the hasNext and next methods with int fields (currentIndex and size) and I want that when this class is serialized the currentIndex became zero (i.e. I reset the Iterator). To do this stuff I used the transient keyword with currentIndex field. With my old Application Server (Borland Application Server) it works fine and currentIndex is reseted before I call my EJB method, but with JBOSS (with the same JVM) it doesn't work and my currentIndex isn't seted to zero. Of course I could put a method reset in my class that solve the problem and call it before the serialization. With this modification the problem was solved, but I want to know if it is a JBOSS bug, JVM Bug, etc...
      Somebody have ideas, comments ??

        • 1. Re: Transient Keyword problem ??

          JBoss optimizes away the serialization within the same
          VM, turning your remote invocation into a local one.

          Regards,
          Adrian

          • 2. Re: Transient Keyword problem ??
            joaocm

            Don't you think that this kind of optimization (that changes the expected behavior of a keyword) have some troubles ? I don't know if is possible to know if some field is transient or not with reflection, but I'm sure that this "problem" have wasted a lot of my time :-).

            João