At the source code level, Java has a rich type system. But at the bytecode level, the Java Virtual Machine operates on a much simpler, more efficient set of computational types. For the JVM, most of your variables are just int.
This fifth chapter in our Java SE 25 deep dive explores JVMS Chapter 2, focusing on how data is represented and manipulated on the stack. We'll uncover the discrepancy between language types and computational types and shed light on the most enigmatic type in the specification: returnAddress.
In this article, you'll learn:
- The difference between Category 1 (32-bit) and Category 2 (64-bit) types and why it matters for stack instructions like
pop/pop2anddup/dup2. - How the JVM promotes
byte,short,char, andbooleantointfor all computational purposes. - The story of the
returnAddresstype, a primitive with no Java equivalent, used for the now-forbiddenjsr/retsubroutines. - The concept of Word Tearing and why
volatileis the specified solution forlonganddoublein multi-threaded code.
Read the full article: https://eldritch.codes/en/tome/tome/tome-01-lexical-foundations/chapter-04
Part of the "Eldritch Codes" series — a comprehensive guide to Java SE 25, explored through the lens of the JLS and the original specs.
Top comments (0)