codegen-java: Support generating record classes #247

Open
opened 2025-12-30 01:22:40 +01:00 by adam · 4 comments
Owner

Originally created by @odenix on GitHub (Nov 12, 2024).

codegen-java should support generating record classes instead of regular classes whenever possible.
(codegen-kotlin already generates data classes whenever possible.)

I have this almost working, but one important question remains: how to deal with backward compatibility?

One option is to introduce a —generate-records flag and only generate record classes if this flag is set.
Another option is to ask users to stay on the 0.27 code generator until they are ready to switch to record classes.
In any case, generating record classes should eventually become the default.

Originally created by @odenix on GitHub (Nov 12, 2024). codegen-java should support generating record classes instead of regular classes whenever possible. (codegen-kotlin already generates data classes whenever possible.) I have this almost working, but one important question remains: how to deal with backward compatibility? One option is to introduce a `—generate-records` flag and only generate record classes if this flag is set. Another option is to ask users to stay on the 0.27 code generator until they are ready to switch to record classes. In any case, generating record classes should eventually become the default.
adam added the enhancement label 2025-12-30 01:22:40 +01:00
Author
Owner

@bioball commented on GitHub (Nov 13, 2024):

Yeah, definitely. Now with Java 11 dropped, the code generator should generate records. I think this is okay as a breaking change (generate java records by default, require flag to retain old behavior).

@bioball commented on GitHub (Nov 13, 2024): Yeah, definitely. Now with Java 11 dropped, the code generator should generate records. I think this is okay as a breaking change (generate java records by default, require flag to retain old behavior).
Author
Owner

@odenix commented on GitHub (Nov 19, 2024):

Blocked on #790.

@odenix commented on GitHub (Nov 19, 2024): Blocked on #790.
Author
Owner

@raymyers commented on GitHub (Jan 10, 2025):

Blocked on #790.

So that might mean unblocked now then? 🤞

@raymyers commented on GitHub (Jan 10, 2025): > Blocked on #790. So that might mean unblocked now then? 🤞
Author
Owner

@bioball commented on GitHub (Mar 1, 2025):

Implementation: https://github.com/apple/pkl/pull/970

@bioball commented on GitHub (Mar 1, 2025): Implementation: https://github.com/apple/pkl/pull/970
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#247