I run my first agent on dacapo, and it works.
need to further figure out whether I miss some classes by the customized class loader (review code of tamiflex).
The agent detects how many objects are created. It is extended from others' tool.
1) I move the instantiation of samplers from client classes into agent's premain(). Clearly, the samplers will also take effect in the period from the agent's premain() to client class's main().
2) run the agent: java -javaagent=gen.jar -jar dacapo.jar avrora
Trace:
...
I just allocated the object ./scratch/test/tinyos/RfmToLeds.elf of type java/io/File whose size is 16
I just allocated the object of type java/lang/StringBuilder whose size is 16
===== DaCapo 9.12 avrora starting I just allocated the object of type java/lang/StringBuilder whose size is 16
=====
======================================
review for the treament in tamiflex project of classes loaded by customer class loader:
All you need to do is add a transformer to the instrumentor instance (given as an argument in premain).Then, the instrumentor will internally transform all classes loaded by all classloaders.
It transforms by invoking the transform(classloader, class,...) provided by each transformer class.
As seen, any class loaded by any classloader is transformed and the relevant information is passed by the jvm to the arguments.