Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wiki Markup
"An inner class is a nested class that is not explicitly or implicitly declared {{static}}." \[[JLS 05|AA. Java References#JLS 05]\]. Serialization of inner classes (including local and anonymous classes) is error prone. According to the Serialization Specification \[[Sun 06|AA. Java References#Sun 06]\]:

...

Compliant Solution

This compliant solution recommends against discourages implementing the Serializable interface in the InnerSer class.

Code Block
bgColor#ccccff
public class OuterSer implements Serializable {
  private int ssn;
  class InnerSer {
    protected String name;
    //...
  }
}

Compliant Solution

It is also allowable to declare the inner class as static to prevent its serialization.

...

Attempts to serialize inner classes can cause instances of the outer class to be serialized and also discourage introduce platform independencedependencies.

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

SER33- J

medium

likely

low

P18

L1

...