JVM Data Types Explained

Oshan Vikasith
3 min readMar 6, 2022
Photo by Markus Spiske on Unsplash

In this article we are going to discuss the data types which are associated with the JVM. These data types are more or less similar to the data types which are used in java programming aspects.

There are two types of data types in JVM, they are as follows

  1. Primitive Data Type
  2. Referenced Data Type

What is the primitive data type ?

In the primitive data type it will hold the value in the variable itself.

What is the Referenced data type?

In the referenced type it will hold the reference to the value.

Primitive Data Type

In the primitive type all the data types except Boolean act the same as the data types which involve when programming java. The difference with the Boolean data type is that it gets slightly less support from the instruction set. Because of that Boolean is always referred to in the JVM by either integer or byte.

  • Boolean False is represented as — 0
  • Boolean True is represented as — 1

The Sizes of these data types are similar in every environment. The long data type takes size as 64 bit in every implementation that does not change with respect to platform. That’s the only difference in the data types.

There is a unique data type which consists in the primitive data types, that is the Return Address type. The Return address data type is used to implement the final block. This data type is not accessible for the developers, it is used only in JVM.

Figure 1: Primitive Data Type Distribution

Referenced Data Type

In the referenced data type it will store the reference to the variable.

Under referenced type these variables types exist.

  1. Class Type
  2. Interface Type
  3. Array Type

Class Type

Referenced to instance of class type.

Interface Type

Interface type is referenced to class implementation.

Array Type

Referenced to array.

Word Size In JVM

Word size is used as a unit in obtaining data values in JVM. The length of the word size is decided by the particular JVM implementation.

There are two rules that need to be obeyed when defining word size

  1. Particular word size should be able to hold any primitive data type.

Eg-: if we have any word and if there is a variable in integer type named as “value” then word should be able to hold the variable “value”

2. Two word sizes need to be used for long or double values.

So at least this word size should be at 32 bits.

In internal implementation of JVM, word size is widely used..

Eg -: In the java stack, there is a special location where it will store local variables. If you insert an integer type primitive variable then this variable should be held by one word. If it is double or long then it should be held by two word sizes

JVM Data type Analyzed Diagram.

Figure 2: JVM Data Types

Hope you got a clear and better understanding regarding the core fundamental aspects of java. Hope to see you again in a future article, Thank you for reading !

Here I have included the sources which I have referred.

(4211) JVM part 03 — Data Types in JVM — YouTube

--

--