2 Replies Latest reply: Apr 19, 2011 7:18 AM by Rafael Soares (Tuelho) RSS

Access to the Instrumentation impl from Helper

Rafael Soares (Tuelho) Newbie

Is possible to expose the inst attribute from HelperManager via an accessor to use it on rule's actions (through default Helper)?

Would be nice to use some usefull methods from the Instrumentation impl like the 'getObjectSize(Object objectToSize)'.

 

May be a new method in org.jboss.byteman.rule.helper.Helper to wrap the getObjectSize from the Instrumentation.

 

Cheers!

  • 1. Access to the Instrumentation impl from Helper
    Andrew Dinn Master

    Rafael Soares wrote:

     

    Is possible to expose the inst attribute from HelperManager via an accessor to use it on rule's actions (through default Helper)?

    Would be nice to use some usefull methods from the Instrumentation impl like the 'getObjectSize(Object objectToSize)'.

    Possible, yes. Desirable no. Access to the Instrumentation instance is quite deliberately kept private to Byteman so as to limit the places where Byteman exposes its functionality to i) the Java command line and ii) the agent listener port. In fact HelperManager should not really include this field (it never uses it).

     

    May be a new method in org.jboss.byteman.rule.helper.Helper to wrap the getObjectSize from the Instrumentation.

     

    That's maybe a possibility. Can you tell me why you want it? Better still, if you do want this then you could raise a JIRA on the Byteman project explaining the need for it?

     

    I think it would be better to locate this functionality on Byteman's Rule class though, rather than in the default Helper class. n.b. this would still allow your helper to access the functionality. You can obtain the associated rule for your helper at create time by providing your helper class with a constructor which takes a Rule as argument.

  • 2. Access to the Instrumentation impl from Helper
    Rafael Soares (Tuelho) Newbie

    Hi Andrew! Many thanks by reply.

     

    I had needed this to use an another API [1] that provides a way to get the aproximated size of an object instance. In fact this API was designed to be an javaagent - that's why it uses an Instrument impl.

     

    My case is a quite specific. I wrote a rule [2] that use the SizeOf API [1] as a javaagent. I'm thinking on another way to get java object's sizes using an API that isn't a javaagent.

     

    [1] http://sourceforge.net/projects/sizeof/

    [2] http://community.jboss.org/thread/165472