Return to site

โ˜•๐Ÿ†• Primitive objects in Java

November 12, 2022

You know how Java splits everything into primitives and reference types and you can only create the latter?

Get ready to have that worldview shattered! ๐Ÿ‘Š๐Ÿ’ฅ๐Ÿ’ฃ๐Ÿงจ

Out of Project Valhalla comes Java Enhancement Proposal 401.

It proposes a distinction between 1๏ธโƒฃ primitive class and 2๏ธโƒฃ identity classes, both can be created by us developers.

1๏ธโƒฃ Instance of the former, called primitive objects, will have no identity but the potential of the same performance and memory benefits as today's primitives. ๐Ÿ˜ƒ

2๏ธโƒฃ Instances of the latter, called identity objects, behave like today's class instances.

This JEP is not โŒ yet targeted ๐ŸŽฏ for a release, so we don't know which Java version will eventually contain ๐Ÿ”ฎ.

#java #primitive #class