Protobuf Meets Valhalla: Hacking with Java Value Classes (JEP 401)
dariobalinzo.medium.com·5h·
Discuss: Hacker News
Flag this post

4 min read14 hours ago

Press enter or click to view image in full size

I like messing with new Java features. This time I tried combining value classes (JEP 401) with Protocol Buffers, not because I needed to, but because protobuf messages are a perfect playground for a lot of small, repeated objects and I wanted to see what happens if those objects could be value classes. JEP 401 is still preview/experimental, and the Valhalla early-access builds let you try it out.

This post is a short write-up of an experiment I did for fun: I wrote a **protoc** plugin that generates value-class-based protobuf messages. The repo/README with quick details is here.

*TL;DR: *value classes can improve memory layout

Similar Posts

Loading similar posts...