Conclusion - Java Reflection API

As you have seen, the Reflection API can be used to simplify code which depends on objects of type unknown before run-time. Reflection is already an integral part of JavaBeans, an extension to Java used in generating appealing user interfaces. This ability of Reflection to work with such a wide variety of objects and arrays of unknown type or specification, truly comes in handy.

Such a powerful tool for code-generation comes at a price, however; the cost of using this API is run-time. Applications that employ Reflection tend to take significantly longer to execute than their counterparts implemented solely with the standard Java APIs. In addition, code written with Java Reflection is sometimes error-prone, since it relies on dynamic checks to guarantee its integrity. A new tool, Type Directed Java (TDJ), is being developed in order to eliminate this sacrifice and potential hazard. Among other benefits, TDJ will provide the functionality of Java Reflection without the run-time tradeoff.

Previous Example
Next Example
Source Code