是类型的序列化触发类型的字段
假设我们有一些类:
class Foo implements Serializable { }
还有一些接口:
interface Bar extends Serializable { }
如果我们有这样的实现:
class X implements Bar {
private final Foo foo;
}
Sonarqube会警告X类中的字段应该是可序列化或瞬态的。序列化那么为什么会出现此警告? foo
的类型是否明确需要序列化
,尽管已经通过继承序列化?
在Sonarlint上验证的环境
6.7.0.45926连接到Sonarqube Enterprise Edition 7.9.4(构建35981)以及Sonarlint Standalone 6.7.0.45926在Intellij中。
Let's say we have some class:
class Foo implements Serializable { }
And some interface:
interface Bar extends Serializable { }
If we have an implementation like this:
class X implements Bar {
private final Foo foo;
}
SonarQube will warn that fields should be Serializable or transient in class X. foo
in this case is-a Serializable
so why does this warning appear? Does the type of foo
explicitly need to be Serializable
despite already being Serializable through inheritance?
Environment
Verified on SonarLint 6.7.0.45926 connected to SonarQube Enterprise Edition Version 7.9.4 (build 35981), as well as SonarLint standalone 6.7.0.45926 in IntelliJ.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论