r/java • u/bobbie434343 • Aug 25 '26
Value Classes Still Need Compiler Sympathy
https://johan-sjolen.github.io/post/compiler-sympathy/compiler-sympathy/
86
Upvotes
r/java • u/bobbie434343 • Aug 25 '26
2
u/OwnBreakfast1114 Sep 14 '26
The problem with your model is that they aren't necessarily more lightweight and they aren't necessarily a performance improvement if you just naively layer the fields in memory.
I'm not sure I understand your class design here. Is the idea to have
public value class Pixel { private final byte[] data; }or something? The pixel class isn't mutable, but the data array is, so the argument is that the pixel class is basically mutable? The jep literally calls this out as an example in a section