concept JVM in category chaos engineering

This is an excerpt from Manning's book Chaos Engineering.
But there is more, because Java and the JVM offer some unique and interesting features that you can leverage for the practice of chaos engineering. I'll focus on those in this chapter. So instead of using one of the techniques you’ve learned before, let’s approach it differently. Let’s modify an existing method on the fly to throw an exception so that you can verify your assumptions about what happens to the system as whole. Let me show you what I mean by that.
One of the key design goals of Java was to make it portable -- write once, run anywhere (WORA) principle. To that end, Java applications run inside of a Java Virtual Machine (JVM). When you run an application, it’s first compiled from the source code (.java) into Java bytecode (.class), that can then be executed by any compatible implementation of the JVM, on any platform that supports it. The bytecode is independent of the underlying hardware. This process is summed up in figure 7.1.
Figure 7.1 High-level overview of running Java code
![]()
What does a JVM look like? You can see the formal specs for all Java versions for free at https://docs.oracle.com/javase/specs/ - and they are pretty good. Take a look at the Java 8 JVM specification (that’s the version you’re running in the VM that is shipped with this book) at https://docs.oracle.com/javase/specs/jvms/se8/jvms8.pdf. It describes the format of a .class file, the instruction set of the VM (similar to an instruction set of a physical processor), as well as the structure of the JVM itself. It’s good to know that you can always look things up in the formal specification. But nothing teaches better than doing things ourselves, so let’s get our hands dirty and look at what this process is like in practice. You want to go modifying other people’s bytecode, so before you do that, let’s first peek into what the bytecode actually looks like.
cat ~/src/examples/jvm/org/agent/ClassPrinter.java