rspec/rules/S2060/java/rule.adoc
2022-02-04 16:28:24 +00:00

35 lines
859 B
Plaintext

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.
== Noncompliant Code Example
[source,java]
----
public class Tomato implements Externalizable { // Noncompliant; no no-arg constructor
public Tomato (String color, int weight) { ... }
}
----
== Compliant Solution
[source,java]
----
public class Tomato implements Externalizable {
public Tomato() { ... }
public Tomato (String color, int weight) { ... }
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
endif::env-github,rspecator-view[]