3 Replies Latest reply on Mar 20, 2013 4:56 AM by Andrew Dinn

    Full acccess to an object with byteman

    Newbie

      Is it possible to have full access to an object using byteman so that the instance members values can be change at runtime to enforce certain behaviour.

      I've been playing a bit with it, has someone used byteman to mofify objects at runtime?

        • 1. Re: Full acccess to an object with byteman
          Andrew Dinn Master

          Hi Albert

          Albert Tresens wrote:

           

          Is it possible to have full access to an object using byteman so that the instance members values can be change at runtime to enforce certain behaviour.

          I've been playing a bit with it, has someone used byteman to mofify objects at runtime?

           

          Yes, you can update objects at runtime. You can call a setter if it exists or you can even assign a field directly

           

          e.g a rule could reset a boolean field belonging to a trigger class instance as follows

           

          . . .

          DO $0.isValid = false;

          ENDRULE

           

          Note that Byteman rules are able to update fields even if they are private (this is true assuming you are using the default JDK security policy -- if you set up a more restrcitive policy then it may not work).

           

          regards,

           

           

          Andrew Dinn

          • 2. Re: Full acccess to an object with byteman
            Newbie

            Hi Andrew thanks a lot!!

            I mange to change the field.

            I am now trying to change a field belonging to a trigger class that has a specific ID value.

            That is a class ResponseStatus that has a field ID and a field isValid change isValid only for ID=1234

            • 3. Re: Full acccess to an object with byteman
              Andrew Dinn Master

              Hi Albert

              Albert Tresens wrote:

               

              I am now trying to change a field belonging to a trigger class that has a specific ID value.

              That is a class ResponseStatus that has a field ID and a field isValid change isValid only for ID=1234

               

              Well, that ought to be easy. Just place the test 1234 in your rule's IF clause.

               

              RULE example

              CLASS ResponseStatus

              METHOD myInstanceMethodName

              AT ENTRY

              IF $0.ID == 1234

              DO $0.isValid = false

              ENDRULE

               

              regards,

               

               

              Andrew Dinn