RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

Andrew Dinn adinn at openjdk.org
Mon Jan 29 14:34:04 UTC 2024


On Sat, 27 Jan 2024 05:11:28 GMT, Alexander Kriegisch <duke at openjdk.org> wrote:

> Bytecode transformation should not be rocket science, but it progressively is developing in that direction.

Hmm? Bytecode transformation of the JDK runtime implementation is a lot more complicated than your comments seem to acknowledge and, here's the important thing, *it always has been*. You need to remember that instrumenting JDK runtime code involves rebuilding the engine that you are driving while you are in mid-flight. If you think there are few-to-none hidden gotchas involved in doing that then I suggest you are significantly underestimating the opportunity for things to go wrong -- not just when it comes to instrumenting some specific release of OpenJDK but also when it comes to keeping instrumentation working across legacy and future releases, with all the variety of moving parts that the (necessary) development of the platform requires. 

The same observation explains why project Jigsaw was needed. The danger of clients using internal JDK runtime APIs -- especially the core runtime APIs -- is much more subtle than many of the programmers who have routinely relied on it recognize. The biggest threat is that public runtime APIs are often implemented via calls to multiple internal APIs -- which may themselves involve multiple entries and re-entries to the JVM. It has always been (and always will be) the case that an isolated call from a client to an internal API can leave the JDK runtime and/or the JVM in an incoherent state because correct use of that internal API requires a correct sequence of invocations with matched inputs and outputs. It is easy even for OpenJDK developers to fails to get this right, especially when calls involve entry to the JVM. The possibility for a programmer who is not very familiar with the JDK runtime code and the JVM code to get it wrong are significant. Worse, the problems may not manifest 
 immediately or in all cases so the danger can be unapparent until disaster strikes.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/3546#issuecomment-1914812297


More information about the core-libs-dev mailing list