Skip to content

[MNG-8493] 'serialVersionUID' can be annotated with '@Serial' annotation#2025

Closed
RainYuY wants to merge 1 commit intoapache:masterfrom
RainYuY:MNG-8493
Closed

[MNG-8493] 'serialVersionUID' can be annotated with '@Serial' annotation#2025
RainYuY wants to merge 1 commit intoapache:masterfrom
RainYuY:MNG-8493

Conversation

@RainYuY
Copy link
Member

@RainYuY RainYuY commented Jan 5, 2025

No description provided.

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly this feels like noise to me. I don't think it's important enough to justify the screen real estate it takes

*/
public class MavenBaseLogger extends LegacyAbstractLogger {

@Serial
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does org.slf4j.helpers.AbstractLogger implements Serializable in the first place ?
What's the use case for serialising those ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe only the SLF4J team knows the exact use case. My guess is that it might involve transmitting logger objects over a network. However, if AbstractClass implements Serializable, I think we should also define a serialVersionUID.

Copy link
Contributor

@elharo elharo Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly there is none. It's just something developers put in 20 years ago because maybe it would help someone somewhere. Java object serialization isn't much used these days, and Brian Goetz uses it as a canonical example of a really interesting antipattern in software design and development:

https://www.youtube.com/watch?v=n6K_8s3Sx4s
https://www.youtube.com/watch?v=dOgfWXw9VrI&t=1957s

What can I say? It was 1997 and none of us really knew what we were doing yet, Sun included.

Interestingly, some of the initialization issues that make Java serialization dangerous are the same reasons we should move away from field injection with Plexus to constructor injection with Guice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can safely remove the serialVersionUID from MavenBaseLogger

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.I have done it.

@gnodet gnodet added this to the 4.0.0-rc-3 milestone Jan 8, 2025
@RainYuY RainYuY closed this by deleting the head repository Jan 9, 2025
@jira-importer
Copy link

Resolve #9944

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants