摘要:
Large software projects often require the ability to load and manage new code assets that were not originally available during system
compilation. Moreover, testing tools need to inspect and run code components regardless of their structures. Reflection in Java supports
these tasks by providing programmers with facilities to dynamically create objects, invoke methods, access fields, and perform code introspection
at runtime. These capabilities come at the cost of reduced readability and writeability, since code written using Java's reflection classes is
clunky, bulky and unintuitive. Common tasks such as object creation, method invocation, and field manipulation need to be decomposed into
multiple steps that require try-catch blocks to guard against checked exceptions. Type casts and explicit use of class types as parameters make
development and maintenance of code difficult, time consuming and error prone. In this paper, we discuss the difficulties of using reflection
in Java. We also present an open-source library called ReflectionSupport that addresses these problems and makes reflection in Java easier to
use. ReflectionSupport provides static helper methods that offer the same reflective capabilities but that encapsulate the overhead of coding
with reflection. This paper focuses on improving the usability of Java reflection by presenting an API that allows programmers to obtain the
benefits of reflection without the hassle.