All Downloads are FREE. Search and download functionalities are using the official Maven repository.

resources.report.rules.pmd.MissingSerialVersionUID.html Maven / Gradle / Ivy



MissingSerialVersionUID

MissingSerialVersionUID

Serializable classes should provide a serialVersionUID field.

    
//ClassOrInterfaceDeclaration
 [
  count(ClassOrInterfaceBody/ClassOrInterfaceBodyDeclaration
   /FieldDeclaration/VariableDeclarator/VariableDeclaratorId[@Image='serialVersionUID']) = 0
and
  count(ImplementsList
   [ClassOrInterfaceType/@Image='Serializable'
   or ClassOrInterfaceType/@Image='java.io.Serializable']) =1
and
   @Abstract = 'false'
]

Example(s):


public class Foo implements java.io.Serializable {
 String name;
 // Define serialization id to avoid serialization related bugs
 // i.e., public static final long serialVersionUID = 4328743;
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy