JVM

Peering through the peephole: build a peephole optimiser using the new Java 24 Class-File API

January 17, 2025 - 15:38

Originally published as part of Java Advent 2024. You can find the full code for the optimiser over on GitHub.

When you think about code optimisation, you might imagine complex analysis over entire programs, sophisticated JIT compilers, or elaborate data-flow analyses. But some of the most effective optimisations come from a much simpler technique: peephole optimisation. This approach can yield surprisingly good results with relatively little complexity.

JEP 457 Hello World

October 5, 2023 - 17:45

This is an updated version of the Java Advent 2022 "JVM Hello World" using the JEP 457 Class-File API.

Writing a “Hello World” program is often a rite of passage for a software engineer when learning a new language.

If you’re a Java developer,  you might even remember the first time you typed public static void main(String[] args) in your editor of choice. But did you ever wonder what’s inside that “.class” file that the compiler spits out? Let’s look at how we can write a JVM “Hello World” by creating a class file programmatically.

We’ll work through creating a class file for the following simple Java Hello World application.

JVM Hello World

January 9, 2023 - 17:47

Writing a “Hello World” program is often a rite of passage for a software engineer when learning a new language.

If you’re a Java developer,  you might even remember the first time you typed public static void main(String[] args) in your editor of choice. But did you ever wonder what’s inside that “.class” file that the compiler spits out? Let’s look at how we can write a JVM “Hello World” by creating a class file programmatically.

We’ll work through creating a class file for the following simple Java Hello World application.

Subscribe to JVM