2 Replies Latest reply on Oct 16, 2012 8:27 AM by whitingjr

    Unknown local variable WARNING.

    whitingjr

      Hi,

      When using bmcheck on a Byteman script I am seeing two warnings. The script attempts to use a scoped reference to an exception in an expression.

      Looking at the documentation I don't see exceptions listed in the Rule Expressions section. Is a rule expression allowed to use an exception reference ?

       

      This is the WARNING message:

       

      $ ~/java/jboss/byteman/byteman-download-2.1.0/bin/bmcheck.sh -cp ~/java/projects/sample-byteman-verify-error/src/main/java/ ~/java/projects/sample-byteman-verify-error/src/main/resources/ExceptionCauseCounter.btm

      checking rule debug cause of exception against class org.jboss.perf.TimedOutExceptionThrower

      WARNING : Warning type checking rule "debug cause of exception" loaded from /home/whitingjr/java/projects/sample-byteman-verify-error/src/main/resources/ExceptionCauseCounter.btm line 10 against method main(java.lang.String[]) void

      org.jboss.byteman.rule.exception.TypeWarningException: unknown local variable $e for method main(java.lang.String[]) void

       

      WARNING : Warning type checking rule "debug cause of exception" loaded from /home/whitingjr/java/projects/sample-byteman-verify-error/src/main/resources/ExceptionCauseCounter.btm line 10

      org.jboss.byteman.rule.exception.TypeWarningException: failed to find any matching trigger method in class org.jboss.perf.TimedOutExceptionThrower

       

      TestScript: 2 total warnings

                  2 type warnings

       

       

      This is a sample application and Byteman script. I was using.

       

      package org.jboss.perf;

       

      import java.lang.Exception;

       

      public class TimedOutExceptionThrower

      {

         public static void main(String args[])

         {

            try

            {

               throw new Exception("Connetion timed out");

            }

            catch (Exception e)

            {

               System.out.println("An exceptional situation ocurred.");

            }

         }

      }

       

       

      ########################################################################

      #

      # Print a debug message when the cause has "timed" in the message text

      #

       

      RULE debug cause of exception

      CLASS org.jboss.perf.TimedOutExceptionThrower

      METHOD main

      AT LINE 15

      IF -1 != $e.getMessage().indexOf("timed")

      DO

         debug("Byteman rule has identified a significant situation.")

      ENDRULE

       

       

      Regards,

      Jeremy

        • 1. Re: Unknown local variable WARNING.
          adinn

          Hi Jeremy,

           

          I think you merley forgot to compile this with debug info. i.e.

           

          [adinn@sputstik jeremy]$ javac org/jboss/perf/TimedOutExceptionThrower.java

          [adinn@sputstik jeremy]$ bmcheck -cp . rule.btm

          checking rule debug cause of exception against class org.jboss.perf.TimedOutExceptionThrower

          WARNING : Warning type checking rule "debug cause of exception" loaded from rule.btm line 10 against method main(java.lang.String[]) void

          org.jboss.byteman.rule.exception.TypeWarningException: unknown local variable $e for method main(java.lang.String[]) void

           

          WARNING : Warning type checking rule "debug cause of exception" loaded from rule.btm line 10

          org.jboss.byteman.rule.exception.TypeWarningException: failed to find any matching trigger method in class org.jboss.perf.TimedOutExceptionThrower

           

          TestScript: 2 total warnings

                      2 type warnings

           

          whereas

           

          [adinn@sputstik jeremy]$ javac -g org/jboss/perf/TimedOutExceptionThrower.java

          [adinn@sputstik jeremy]$ bmcheck -cp . rule.btm

          checking rule debug cause of exception against class org.jboss.perf.TimedOutExceptionThrower

          parsed rule "debug cause of exception" for class org.jboss.perf.TimedOutExceptionThrower

          type checked rule "debug cause of exception"

           

          TestScript: no errors

           

          regards,

           

           

          Andrew Dinn

          • 2. Re: Unknown local variable WARNING.
            whitingjr

            Hi Andrew,

            Thank you for spotting that.

             

            Regards,

            Jeremy