r/java • • Jul 14 '26

New candidate JEP: 401: Value Objects (Preview)

https://mail.openjdk.org/archives/list/valhalla-dev@openjdk.org/thread/IUNJJ3WP3X3XHP3QZTXXSSCPKFDNTK3W/
87 Upvotes

45 comments sorted by

View all comments

Show parent comment

3

u/kiteboarderni Jul 14 '26

Or use a primitive collection wrapper in the mean time like people have done for years. Then swap out when it's in a preview state.

1

u/IncredibleReferencer Jul 15 '26

With a primitive collection wrapper I could use a list instead of an array for sure, but I couldn't add my own wrapper type object without a major memory/indirection penalty (for very large item counts) for both the wrapper. So valahalla should allow both (List<Integer> and List<MyWrapper> in a memory efficient and flat reference way. I think.