rspec/rules/S2060/java/rule.adoc

24 lines
670 B
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
An ``++Externalizable++`` class is one which handles its own ``++Serialization++`` and deserialization. During deserialization, the first step in the process is a default instantiation using the class' no-argument constructor. Therefore an ``++Externalizable++`` class without a no-arg constructor cannot be deserialized.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
public class Tomato implements Externalizable { // Noncompliant; no no-arg constructor
public Tomato (String color, int weight) { ... }
}
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
----
public class Tomato implements Externalizable {
public Tomato() { ... }
public Tomato (String color, int weight) { ... }
}
----