r/java • u/davidalayachew • Jul 16 '26
Identifying JDK value class candidates
https://mail.openjdk.org/archives/list/core-libs-dev@openjdk.org/thread/Y72NRXM7KYBX43OKYBQMVKOZDWKG4MHS/
53
Upvotes
View all comments
Show parent comment
1
u/RussianMadMan Jul 16 '26
In every example in java valhalla videos you can see a class like a Point thats declared "value record" with a method like:
public Point move() { return new Point(x + 0.5, y);}
Which "mutates" point by recreating it. And in most cases there will be no allocation during the runtime. So what I meant in my prev comment is that I think we can have Map.Entry declared "value record" class with a method:
public Entry setValue(T value) { return new Entry(key, value);}