Hi Stuart,
On 02/01/2012 09:17 PM, Stuart Douglas wrote:
Did you consider having byteman instrument the Class Loaders in the
target vm, to always delegate to the system class loader if the class
being loading starts with "org.byteman" ?
I am pretty sure this is how JProfiler gets around the need for this
setting.
I did consider this but I decided against it for two reasons:
1) the existing mechanism in JBoss modules already does the basic job of
making Byteman classes available everywhere. So, duplicating it seemed
inefficient both at devtime and at runtime.
2) doing the job properly will also involve adding exemptions for other,
non-Byteman classes referenced at the point of injection and I am
considering a better mechanism to make this work
To explain the latter, imagine that a rule injected into a JBossTS class
needs access EJB types/methods. However, Byteman currently has to
type-check and link the rule using the loader of the target class. So,
you are snookered if the JTS module does not import the EJB classes.
I think I can get round this by adding i) module import statements to
Byteman rule scripts ii) a plugin to the Byteman agent which resolves
module imports and hands Byteman a multi-module loader for
type-check/load, allowing rules to be linked against the union of the
target module and the imported modules.
Of course the plugin and the import syntax would have to be module
loader-specific.So, you would need an OSGI plugin, a JBoss Modules
plugin, a Jigsaw plugin etc. But it should be easy to define a generic
API for delegation of loader issues. So, watch this space.
regards,
Andrew Dinn
-----------