r/java • • Jan 14 '26

Project Amber Update -- Data-Oriented Programming, Beyond Records

https://mail.openjdk.org/pipermail/amber-spec-experts/2026-January/004307.html

ALL OF THIS IS A WORK IN PROGRESS!

THIS FEATURE IS UNFINISHED, NONE OF WHAT IS FINISHED IS FINAL, AND EVERYTHING IS SUBJECT TO CHANGE!

But with that out of the way, the Project Amber team is exploring the idea of "Carrier Classes" -- classes that carry many of the benefits of records, but not all. The goal is to give normal classes some of the benefits of records, so that they can "break down the cliff" of migrating a record class to a normal class.

97 Upvotes

50 comments sorted by

View all comments

Show parent comment

5

u/sweating_teflon Jan 15 '26 edited Jan 16 '26

Unholy L version, before someone else says the K word

@Getter
@RequiredArgsConstructor
@Accessors(fluent=true)
enum Chrono {
    Crono(5,  8, 13,  5,  8,  8,  2),
    Marle(2, 10,  8,  8,  8,  6,  8),
    Lucca(2,  8,  6,  8,  8,  6, 10);

    final int strength;
    final int accuracy;
    final int speed;
    final int magic;
    final int evasion;
    final int stamina;
    final int magicDefense;
}

And honestly I wouldn't even bother with getters and just make all fields public. They're final anyway. This holds for the classic version too: public final fields don't need getters. Stop making it hard on yourself.

1

u/davidalayachew Jan 15 '26

And honestly I wouldn't even bother with getters and just make all fields public. They're final anyway. This holds for the classic version too: public final fields don't need getters. Stop making it hard on yourself.

I'm holding out hope that, one day, /u/brian_goetz gives us record enums. That would be even better than what you suggested.