News for hackers. Stuff that matters.
Re:Java Agents by native_samples on Monday July 05, 2021 @05:41AM (#27736111)
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 J-Kuhn on Monday July 05, 2021 @06:59AM (#27736585)
It's called the Java VM Tool Interface (JVMTI) - and it's C, not C++.

The Java debugger is implemented on top of the JVMTI.

Re:Java Agents by lewich on Monday July 05, 2021 @04:11AM (#27735644)
Suprized to see this on top of HN.
Re:Java Agents by cpach on Monday July 05, 2021 @04:34AM (#27735753)
Why are you surprised?
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.