The ten chapters of this book are organized as follows:
Chapters 1, 2, and 3 introduce the basics of Java reflection: how to access class objects; how to dynamically examine classes, methods, fields, and constructors; and how to dynamically load classes.
Chapter 4 introduces the first advanced reflective feature: dynamic proxies. The chapter covers the facilities of the Proxy class and how to use them. There are several useful examples, including how to add properties to objects and how to create a test stub generator.
Chapter 5 covers the topic of examining the call stack. This is important for reflectively solving problems related to what a running program is doing.
Chapter 6 delves into customizing class loaders. This topic is necessary to reflective programming because some problems require the collection of metadata that is available only when classes are loaded.
Chapter 7 begins a two-chapter sequence on reflective code generation. This chapter introduces a framework for class-to-class transformations, a particular kind of code generator that starts with a compiled class and produces a new compiled class, which usually has some additional property.
Chapter 8 continues the sequence by using the framework for class-to-class transformations to support implementation of designs that use patterns.
Chapter 9 presents performance-measurement techniques for making design decisions among reflective features.
Chapter 10 takes a look at the future of reflection in Java. This includes an overview of the impact of Java 1.5 on reflective programming, which other production languages will influence the future of reflection in Java, and the influence of Aspect-Oriented Programming.
Appendix A is a reprise of the introduction to reflection but with a more academic point of view. The appendix presents a brief history of reflection and the terminology that you are likely to encounter when reading advanced papers.
Appendix B explains how to handle compilation errors in the program that dynamically compiles the "Hello World!" program.
Appendix C summarizes the UML conventions used to diagram reflective programs.
This book is a practical guide for intermediate programmers. The book has one goal: to make your programming job easier. We accomplish this in two ways:
This book is prescriptive. That is, it advocates techniques for using Java reflection that we have used and profited from in our jobs.
The examples in this book have all been compiled and minimally tested. Source code examples are available online from the publisher's web site: www.manning.com/forman. No warranty is implied as to the total correctness of the source code in this book.
In order to make this book as readable as possible, we have adopted a style of Java programming that suits the static line size of the printed page rather than the dynamic interface of the program editor. With this style, we have succeeded in limiting almost all classes to no more than two pages. This style tends to reduce whitespace. We do not recommend this style, but we do hope you appreciate the readability of the book.
Purchase of Java Reflection in Action includes free access to a private web forum where you can make comments about the book, ask technical questions, and receive help from the authos and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/forman. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum. It also provides links to the source code for the examples in the book, errata, and other downloads.
Manning's commitment to our readers is to provide a venue where a meaningful dialog between individual readers and between readers and the authors can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the AO remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions lest their interest stray!