This appendix gives an example of creating a custom tool based on the SigTest tool and its APIs. The example tool checks two implementations of a set of Java classes for serialization compatibility. You can create similar tools based on this example.
This appendix contains the following topics:
The serialization tool is an example of using the SigTest APIs to create a new kind of tool. The serialization tool verifies that two implementations of one set of classes can successfully serialize and deserialize instances of each other. For a description of serialization, see
The serialization tool has two commands and is run much like the base SigTest tool.
$ java com.sun.tdk.sertest.SerSetup [options]
$ java com.sun.tdk.sertest.SerTest [options]
Be certain that
sertest.jar are in the classpath. Most SigTest tool options are valid for the serialization tool.
The serialization tool differs from the base SigTest tool in the following ways:
java.io.Serializable classes are taken (except
For all classes, only non-transient and non-static fields are tracked. Also
serialVersionUID is required and its value is tracked.
Any serializable class must have a
Because of reflection limitations, access to class members via reflection is not supported, and the test command is always static regardless of the
The setup command always generates a
-nonclosed signature file.
Signature files generated by this tool's setup command are incompatible with, and must not be used by, the base SigTest tool or any other custom tool derived from it. Conversely, signature files generated by other tools must not be used with the serialization tool.
The serialization tool is implemented in the
com.sun.tdk.sertest package in
/examples/sertest/. There are three classes:
Main class for setup command
Main class for test command
Common code for setup and test commands
For implementation details, see the Javadoc in the SigTest-Directory