1 Line of Code. Multiple Architectural Subsystems. Sub Seconds latency. We take the JVM for granted, but the journey of a simple System.out.println is more complex than we think. From security checks to Just-In-Time compilation, here is what’s actually happening under the hood when we run our life's first Java program, "Hello World!". We have seen this diagram thousands of times, but every time you go through its components, you will realize how much you don't know about how JVM works. #Java #JVM #SoftwareEngineering #helloworld
the part that always gets me is the class loading chain. people think javac compiles and thats it, but the bytecode verification step alone is doing type inference on the operand stack to prove your code wont corrupt the JVM. and then theres the JIT tiering, C1 compiles everything quickly with basic optimizations while profiling, and only the hot methods get promoted to C2 for aggressive optimizations like loop unrolling, escape analysis, and inlining. the escape analysis part is wild because the JVM can actually eliminate heap allocations entirely if it proves the object doesnt escape the method scope, which means your new Object() might never touch the heap at all. most people have no idea how much work the JVM does to make their simple println fast.
Link to the blog : https://medium.com/@rednirus/inside-the-jvm-the-journey-of-hello-world-through-the-jvm-architecture-7a743abec119