This is a known problem with the current operation of Byteman.
The solution requires an upgrade to Byteman in 2 separate steps.
- The rule language needs to be modified to support an import statement in rule scripts.
- The rule engine needs to be modified to link rule code by delegating to the loaders for imported classes as well as delegating to the loader for the rule's target class
This really needs to be provided using a plugin model so we can implement each step (import processing and loader delegation) for vanilla JDK and also for Jigsaw, JBoss Modules and OSGi. Clearly, each plugin will need to define an appropriate import syntax and appropriate semantics for how to handle delegation.
I have some ideas for how to provide such an implementation but I don't have time at present to do this myself. If you or anyone else are interested in implementing such a solution I'd be happy to try to help get it working.
Thanks for the clear answer! Contributing for it sounds interesting, but I'm just an user right now, so will need some time to get familiar with the inside of Byteman. That'll be great if somebody else can do before me