JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
Serialization for a class has not been explicitly disabled by
defining a writeObject() method that always throws an
exception.
| Class Name | Serialization Not Disabled (Java) | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | reliability | |||||||||||||||||||||||||||
| Mnemonic | JAVA.CLASS.SER.ND | |||||||||||||||||||||||||||
| Categories |
|
|||||||||||||||||||||||||||
| Availability | Available for Java and Kotlin. |
|||||||||||||||||||||||||||
| Enabling | Checks for this warning class are
disabled by default. To enable them, add the following WARNING_FILTER
rule to the project configuration file.
WARNING_FILTER += allow class="Serialization Not Disabled (Java)" |
In the following code excerpt, class MyWindow is serializable (because it extends serializable class JFrame).
However, the programmer has annotated the class with @SuppressWarnings("serial"), suppressing any compiler warnings about the missing serialVersionUID field. CodeSonar observes this suppression and reasons that the programmer does not intend the class to be serialized. However, serialization has not been explicitly disabled.
// MyWindow.java import javax.swing.JFrame; @SuppressWarnings("serial") public class MyWindow extends JFrame { // "Serialization Not Disabled" warning issued here private final int secret; public MyWindow(int secret) { this.secret = secret; } }
In this example, the programmer should explicitly prevent serialization of class MyWindow, as follows.
// MyWindow.java, after modification
import java.io.ObjectOutputStream;
import javax.swing.JFrame;
@SuppressWarnings("serial")
public class MyWindow extends JFrame {
private final int secret;
public MyWindow(int secret) {
this.secret = secret;
}
private void writeObject(ObjectOutputStream stream) {
throw new RuntimeException("Serialization is not allowed");
}
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.