'@Serial' annotation used on wrong member
Reports methods and fields in the Serializable
and Externalizable
classes that are not suitable to be annotated with the java.io.Serial
annotation.
Examples:
class Test implements Serializable {
@Serial // The annotated field is not a part of serialization mechanism because it's not final
private static long serialVersionUID = 7874493593505141603L;
@Serial // The annotated method is not a part of the serialization mechanism because it's not private
void writeObject(ObjectOutputStream out) throws IOException {
}
}
class Test implements Externalizable {
@Serial // The annotated method is not a part of the serialization mechanism as it's inside Externalizable class
private void writeObject(ObjectOutputStream out) throws IOException {
}
}
For information about all valid cases, refer the documentation for java.io.Serial
.
This inspection only reports if the language level of the project or module is 14 or higher.
New in 2020.3
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023