-
Feature Request
-
Resolution: Won't Do
-
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.
- is duplicated by
-
BYTEMAN-288 Byteman should allow calls to methods of private static inner classes from generated bytecode
- Closed
- relates to
-
BYTEMAN-286 ClassNotFoundException when using ^ where sub class is an inner class
- Closed