0:0016:14

JVM architecture and how it works

Kamila Oliveira 16:14 2021

Java runs your code line by line, then compiles only what you repeat

Every Java program passes through three class loaders, five memory areas and an execution engine that decides which repeated code to turn into native machine code. For anyone writing Java, Kotlin or another JVM language, that machinery explains startup errors, stack overflows and performance. Microsoft MVP and backend developer Kamila Oliveira walks through each layer, asking what really happens between compiling a .java file and running it.

Follow a Java class from bytecode to native code and learn which garbage collector fits your app

Watch on YouTube

In short

Kamila Oliveira, Microsoft MVP and backend developer at Ame Digital, explains how the Java Virtual Machine is built and how it runs code. She walks through the class loader, the five JVM memory areas, the execution engine with its interpreter, JIT compiler and garbage collector, and the native method interface, ending with a step-by-step compile-and-run example.

“Class loader is responsible for three activities into JVM, loading, linking, and initialization.”
“Then this native code is used for repeated methods calls. That improves the performance.”

What you will learn

  • Explain how Java source becomes bytecode and why that lets one program run on any machine with a JVM.
  • Describe the three built-in class loaders and the loading, linking and initialization steps.
  • Identify the five JVM memory areas and what each one stores, from the shared heap to per-thread stacks.
  • Distinguish the interpreter from the just-in-time compiler and see why hotspots get compiled to native code.
  • Choose between the serial, parallel and G1 garbage collectors based on application size and threading.

Key takeaways from the speaker

  • java
  • jvm
  • backend

Details

Level
Beginner
Format
Talk
Technical depth
Introductory technical
For
Student, Early career, Mid-career
Length
16:14
Published
June 2021

Questions this talk answers

What does the JVM class loader do?

It loads, links and initializes classes, bringing compiled .class bytecode into main memory. The bootstrap, extension and application class loaders pass the request down the hierarchy until one finds the class.

What happens if no class loader can find a class?

If neither the parent nor the child class loader can load the class, the JVM throws a NoClassDefFoundError or ClassNotFoundException.

Why does the JVM use both an interpreter and a JIT compiler?

The interpreter reads bytecode line by line, which is slow when a method is called many times. The JIT compiler converts repeated code (hotspots) into native code that is reused for later calls, improving performance.

How does Java garbage collection work?

In the mark step the collector identifies unused objects, and in the sweep step it removes them. It runs automatically at regular intervals, and you can also trigger it with System.gc().

Which garbage collector should I choose?

The serial collector suits small single-threaded applications, the parallel collector uses multiple threads, and G1 is recommended for multithreaded applications with a large heap because it divides the heap into equal regions and collects the most garbage-heavy ones first.

About this talk

let's talk about jvm, how it works and what is its architecture. Let's see what are class loader, method area, heap, execution engine, Native method interfaces and libraries and what all this does in the process of compiling our applications.

Topics

Related talks

Browse the library