7.8. Generating Custom Serialization Code
Serialization is the perfect example of a generic service. Simply mark your object as Serializable, and at runtime the ObjectOutputStream class and friends will use reflection to extract/construct your object's instance state. Unfortunately, default serialization's heavy use of reflection imposes a performance penalty that is noticeable in some situations. In Chapter 4, you saw several options for manually customizing serialization. Some of these options could be used to improve serialization performance, but they would require you to hand-author the serialization code.
Generative programming offers an attractive middle ground. A generator can use reflection to generate custom code that is more efficient ...
Get Component Development for the Java™ Platform now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.