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

Instances of anonymous classes cannot be accessed via bound vars in compiled rule code

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • 2.1.2
    • None

      When a binding is looked up during rule execution the compiled code for the rule plants a call to HelperAdapter.getBinding() (which return an Object) followed by a checkcast to the relevant class (or an unbox for primitives). This is normally necessary to ensure that subsequent uses of the inctance are type safe.

      In the case where the class is anonymous this leads to a bytecode verification failure because it is only legal to refer to an anonymous class from methods of the enclosing class. The generated code is, of course, created as method execute0 attached to a subclass of the rule's helper class.

      Of course, a similar verification failure occurs if the anonymous instance is accessed directly using get/setfield or invokeXXX bytecodes. However, the compiler could be modified to implement such accesses using reflection (as is done with accesses to private members). In these cases it would be safe to omit the cast after the lookup (reflective access is generic).

      The only problem is that other uses of the retrieved value (e.g. passing an anonymous object as argument to a method call) would then cause type check failures because a generic Object was being used where an instance of the anonymous class is expected. This could be highly confusing at the very least. So, without some way of detecting such usages this is probably not a viable fix.

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

                Created:
                Updated:
                Resolved: