-
Notifications
You must be signed in to change notification settings - Fork 77
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
Java 17 recipe add serialVersionUUID and @Serial by default #560
Conversation
The CI/CD log is very confusing on what is failing but doesn't look related to my change? |
Thanks again @melloware ! Good to have these warnings cleared out. |
@timtebeek i just tested this and for some reason its not working. It looks like its looking in the |
That would be quite surprising; did you try it with the latest version just released? |
Yes I will put together a test tomorrow showing the issue. |
Hey @melloware and @timtebeek, I just ran the latest rewrite version and realized it was adding This is absolutely not a safe change, as it will change the value of the (previously generated) Moreover, there are a lot of cases in which you use |
@DidierLoiseau so you are saying it changed private static final long serialVersionUID = 123456789L; to private static final long serialVersionUID = 1L; ?? That would be a bug in the Recipe if so? Also if you had NO declared |
It only added it to classes which didn’t have it.
With this change, it would fail to deserialize WITHOUT version change, since the recipe adds a different value than the one that was previously generated based on the (same) class structure – it is not random by the way. People tend to add the field just to get rid of the warning, and then they don’t maintain it, which will lead to troubles when the class changes without changing the value. It should only be added when people know what they are doing, not blindly by a Java 17 upgrade recipe (which runs even when your code is already in Java 17, btw). Do no harm 😉
|
I can live with that argument!! @DidierLoiseau i will submit a PR to pull it out. |
What's changed?
Adds
serialVersionUUID
and@Serial
to java classes that implementSerializable
as a best practice.What's your motivation?
Many IDE's like IntelliJ and Eclipse report these issues need to be addressed.
Checklist