Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializable record classes should not have serialVersionUID-field by default #219

Open
Chrimle opened this issue Nov 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working MAJOR Breaking change, expected to cause issues and require additional attention

Comments

@Chrimle
Copy link
Owner

Chrimle commented Nov 16, 2024

Describe the bug
As stated here: https://docs.oracle.com/en/java/javase/20/serializable-records/index.html,
there is no need to have this field in generated record classes, as stated:

Specifically, there is no need to add a serialVersionUID field, since the serialVersionUID of a record class is 0L unless explicitly declared, and the requirement for matching the serialVersionUID value is waived for record classes. Rarely, for migration compatibility between normal classes and record classes, a serialVersionUID may be declared, see Section 5.6.2 Compatible Changes of the Java Object Serialization Specification for more details.

To Reproduce
Set configOptions.serializableModel=true

Expected behavior
The field serialVersionUID is not needed, and should thus not be generated.

Additional context & Versions used
This is a bit tricky... this version is 0 by default, and is mostly ignored when deserializing. However, it is needed and does matter when migrating to/from classic java classes.

@Chrimle Chrimle added the bug Something isn't working label Nov 16, 2024
@Chrimle Chrimle self-assigned this Nov 16, 2024
@Chrimle Chrimle added the MAJOR Breaking change, expected to cause issues and require additional attention label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working MAJOR Breaking change, expected to cause issues and require additional attention
Projects
Development

No branches or pull requests

1 participant