Java agents are neat, but what relatively few people realize is that there are two agent APIs, one for agents written in Java and one for agents written in C++. The latter is drastically more powerful but hardly ever used. It exposes all the functionality available to Java agents like class redefinition, and then a lot more.
The C++ API gives you access to, amongst other things: manipulating the stack by reading/writing local variables or forcing early returns with values of your choice, learning what locks a thread holds, walking the heap including unreachable objects, tagging objects, adding field watches, getting the bytecodes of a method, intercepting the entire JNI API, receiving callbacks on dozens of different events including things like field modification, JITC, object allocation and the begin/end of GC.
Very few people really take advantage of this API, even though it can be used to achieve remarkable effects all against public, stable API.
Re:Java Agents
by matsemann on Monday July 05, 2021 @04:50AM
(#27735836)
Because tutorials often aren't featured here. Especially not video tutorials. If it introduced a concept or something it would be more in line what's normal on here. As a Javadeveloper for many years for which this could be relevant, I'm not too interested because it's not selling why it's useful, just diving into lots of code. So to be a bit blunt, but I don't think the quality warrants being on top.
And I know one's not supposed to speculate, but multiple upvotes in short time without any discussion for something of this caliber is a bit off.
The C++ API gives you access to, amongst other things: manipulating the stack by reading/writing local variables or forcing early returns with values of your choice, learning what locks a thread holds, walking the heap including unreachable objects, tagging objects, adding field watches, getting the bytecodes of a method, intercepting the entire JNI API, receiving callbacks on dozens of different events including things like field modification, JITC, object allocation and the begin/end of GC.
Very few people really take advantage of this API, even though it can be used to achieve remarkable effects all against public, stable API.
The Java debugger is implemented on top of the JVMTI.
And I know one's not supposed to speculate, but multiple upvotes in short time without any discussion for something of this caliber is a bit off.