DEV Community

Cover image for JVMS Deep Dive: How the JVM Represents Data — Integers, Floats, and the Mysterious returnAddress
Michele Gallotti
Michele Gallotti

Posted on

JVMS Deep Dive: How the JVM Represents Data — Integers, Floats, and the Mysterious returnAddress

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/pop2 and dup/dup2.
  • How the JVM promotes byte, short, char, and boolean to int for all computational purposes.
  • The story of the returnAddress type, a primitive with no Java equivalent, used for the now-forbidden jsr/ret subroutines.
  • The concept of Word Tearing and why volatile is the specified solution for long and double in 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)