I am looking for a BCI (Bytecode Instrumentation) library for Java in C or C++, to use in a JVMTI agent.
Best case scenario would be something like ASM or BCEL in pure C.
The closest thing I have found so far is only a demo java_crw_demo written by Kelly O'Hair a few years ago and used in Sun's/Oracle's tutorials ever since.
Do you know of anything else?
Some rationale: I am building an instrumentation tool to add a getter method to
java.lang.Objectand overload this getter in every direct subclass ofObject. For this reason I cannot use a Java agent. Also, I would like to avoid spawning a secondary JVM to perform the instrumentation - for complexity and speed reasons.
I once started writing one in C quite a while ago, but I didn't get very far due to lack of motivation. AFAIK there's no public releases in C, but it shouldn't be too hard to write a simple one for your needs according to the JVM Specification. You should be particularly interested in the chapter on the
classfile format, as well as that on the instruction set.