Uploaded image for project: 'Byteman'
  1. Byteman
  2. BYTEMAN-357

Injection into a rule's own helper class may fail

XMLWordPrintable

    • Hide

      Try using script JVMBeanScript.btm which uses helper JMXHelper and tries to inject into JMXHelper.keyInfo(). Injection fails for this rule.

      Show
      Try using script JVMBeanScript.btm which uses helper JMXHelper and tries to inject into JMXHelper.keyInfo(). Injection fails for this rule.
    • Workaround Exists
    • Hide

      Workaround 1: Move the methods into which the desired behaviour is to be injected into an inner class of the helper. The helper class can be loaded without needing to load the inner class and then invoke methods of the inner class to trigger the injected code.

      Workaround 2: Split the script into two and load in two stages. If the first script includes rules for loaded classes (i.e. not the helper) they will force loading of the helper. Loading of the rules which do contain the helper will then succeed because the class is already present so will get transformed.

      Workaround 3: Find some other way to ensure the helper class is loaded before loading the rules which inject into the helper.

      Show
      Workaround 1: Move the methods into which the desired behaviour is to be injected into an inner class of the helper. The helper class can be loaded without needing to load the inner class and then invoke methods of the inner class to trigger the injected code. Workaround 2: Split the script into two and load in two stages. If the first script includes rules for loaded classes (i.e. not the helper) they will force loading of the helper. Loading of the rules which do contain the helper will then succeed because the class is already present so will get transformed. Workaround 3: Find some other way to ensure the helper class is loaded before loading the rules which inject into the helper.

      If a rule R employs helper class H and also specifies H as a target class for the rule then it may not get injected into the target method.

      The problem is a regression caused by a change made to support JBoss Modules that moved helper class loads from trigger time to transform time.

      It arises if the target H has not already been loaded and some other rule gets triggered which targets a different class K but also uses H as its helper. Byteman goes ahead and loads the helper class while in the middle of transforming K. Since transformation is not re-entrant this means that class H does not get presented to Byteman for rule injection.

      The solution is to move helper class loading back to trigger time, ensuring it happens just before rule typecheck.

              rhn-engineering-adinn Andrew Dinn
              rhn-engineering-adinn Andrew Dinn
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: