r/java • • Jul 16 '26

Identifying JDK value class candidates

https://mail.openjdk.org/archives/list/core-libs-dev@openjdk.org/thread/Y72NRXM7KYBX43OKYBQMVKOZDWKG4MHS/
52 Upvotes

59 comments sorted by

View all comments

Show parent comment

1

u/aoeudhtns Jul 16 '26

Enums do have an interesting property of being representable as int via ordinal(), so if you needed that it wouldn't be too much effort to do that and resolve them back with Type.values()[ordinal].

1

u/TwoWeeks90DaysTops Jul 16 '26

Yes, but you lose type safety, null handling, you have to implement manual handling and you have to make a choice about the data size. I also think most of the purpose of Valhalla would disappear if "just decompose your object into primitives" was an acceptable answer.

1

u/aoeudhtns Jul 16 '26

True that.