Java


JAVA.CLASS.SER.UIDU : Unexpected Serial Version Field (Java)

要旨

A serialVersionUID field is defined where it is not expected.

Serialization allows one to dump an object into a file and recover (deserialize) it later. For this to work, Java requires the class of the object to implement the java.io.Serializable interface. Moreover, all instance non-transient fields of the class must be serializable themselves. For inner non-static classes, also the outer class must be serializable. In order to distinguish dumps of objects for distinct versions of the same class, it is required that serializable classes define a static field containing the serial version of the class.

プロパティ

クラス名 Unexpected Serial Version Field (Java)
日本語クラス名 Unexpected Serial Version Field (Java)
クラス分類 信頼性 (reliability)
ニーモニック JAVA.CLASS.SER.UIDU
カテゴリー
CWE CWE:913 Improper Control of Dynamically-Managed Code Resources
対応言語 Java で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Unexpected Serial Version Field (Java)"

解決法

Guarantee that all instance non-transient fields of a serializable class are themselves serializable. Make inner serializable classes have a serializable outer class, or make them static. Add a long serialVersionUID field to serializable classes.

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。