Files
openide/java/java-impl/resources/inspectionDescriptions/NonSerializableObjectPassedToObjectStream.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

23 lines
823 B
HTML

<html>
<body>
Reports non-<code>Serializable</code> objects used as arguments to
<code>java.io.ObjectOutputStream.write()</code>. Such calls will result in runtime exceptions.
<p>
This inspection assumes objects of the types <code>java.util.Collection</code> and
<code>java.util.Map</code> to be <code>Serializable</code>, unless the types
they are declared in are non-<code>Serializable</code>.
</p>
<p><b>Example:</b></p>
<pre><code>
public class IWantToSerializeThis {
public static void main(String[] args) throws IOException {
try(var stream = new ObjectOutputStream(Files.newOutputStream(Paths.get("output")))) {
// Warning -- will fail with NotSerializableException
stream.writeObject(new IWantToSerializeThis());
}
}
}
</code></pre>
<!-- tooltip end -->
</body>
</html>