2 Replies Latest reply on Feb 11, 2015 9:46 AM by Ondra Chaloupka

    Listing content of array as debugging information

    Ondra Chaloupka Expert

      Hi,

       

      I have one more doubt if you don't mind. I would like get listed content of an array which will be then printed by traceln in DO part of the byteman script. How can I achieve this?

       

      My intention is to get listed all values of Xid[] array from Narayana project. The definition of array is here: narayana/XARecoveryModule.java at 4.17 · jbosstm/narayana · GitHub

       

      I've tried a rule like this

      RULE trace xares transactions
      CLASS com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule
      METHOD xaRecoveryFirstPass
      AT LINE 543
      IF true
      DO 
        traceln("Xares[" + $1 + "].recover returned: " + $trans.length + " and content: " + java.util.Arrays.asList($trans));
      ENDRULE
      

      But this try ends with exception

      Rule.ensureTypeCheckedCompiled : error type checking rule trace xares transactions
      org.jboss.byteman.rule.exception.TypeException: DollarExpression.typeCheck : invalid expected type java.lang.Object[] for bound parameter $trans file /tmp/jbosstscrashrectests2529661491284256645 line 11
       org.jboss.byteman.rule.expression.DollarExpression.typeCheck(DollarExpression.java:169)
       org.jboss.byteman.rule.expression.MethodExpression.findMethod(MethodExpression.java:277)
       org.jboss.byteman.rule.expression.MethodExpression.typeCheck(MethodExpression.java:172)
       org.jboss.byteman.rule.expression.StringPlusExpression.typeCheck(StringPlusExpression.java:52)
       org.jboss.byteman.rule.expression.MethodExpression.findMethod(MethodExpression.java:277)
       org.jboss.byteman.rule.expression.MethodExpression.typeCheck(MethodExpression.java:172)
       org.jboss.byteman.rule.Action.typeCheck(Action.java:106)
       org.jboss.byteman.rule.Rule.typeCheck(Rule.java:523)
       org.jboss.byteman.rule.Rule.ensureTypeCheckedCompiled(Rule.java:449)
       org.jboss.byteman.rule.Rule.execute(Rule.java:672)
       org.jboss.byteman.rule.Rule.execute(Rule.java:653)
       com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.xaRecoveryFirstPass(XARecoveryModule.java:543)
       com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkFirstPass(XARecoveryModule.java:181)
       com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:747)
       com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:375)
      

       

      Is there some way? Another possible solution that came to my mind is to create my own helper class. But it seems to me a bit heavy weighted and I haven't try it yet.

       

      Thanks for help

      Ondra