| ## Enhancements to java.lang.Class and java.lang.Reflect | Reflection

Enhancements in 5.0

The changes in java.lang.Class and java.lang.reflect include:

- Support for generics - In particular, the changes support structural program reflection on generic type information. In other words, they make it possible to examine a type, method, constructor or field declaration and obtain generic type information. Specifically, one can determine whether a type, method or constructor declares any type variables, and reflect those type variables to the application program (so that one may learn their names and bounds, for example). One can also obtain the non-erased form of the type of a field, a method or constructor parameter, a method return type or the throws clause of a method or constructor. The generified form of a type name is available via toGenericString(). However, note that we do not provide any support for determining which generic invocation an instance belongs to.
- Support for annotations - This includes the ability to obtain annotations on types, methods, fields, constructors and formal parameters of methods and constructors that have been marked as available at run-time, using the getAnnotation() method. One can also determine whether an interface is an annotation type.
- Support for enums - One can determine whether a class is an enum, and whether a field represents an enum constant.
- Support for var args - One can determine whether a method or constructor is a of variable arity.
- Convenience methods - for establishing whether a class is local, anonymous or a member class, and what a type's simple and cannoical names are. One can also determine whether a member is synthetic (an artifiact by the implementation).
- The generification of class java.lang.Class - This allows the use of instances of java.lang.Class as type tokens. See section 8 of the generics tutorial for examples.

Enhancements in 1.4.0

- Performance enhancements - Beginning with J2SDK 1.4.0, certain reflective operations, specifically java.lang.reflect.Field, java.lang.reflect.Method.invoke(), java.lang.reflect.Constructor.newInstance(), and Class.newInstance(), have been rewritten for higher performance. Reflective invocations and instantiations are several times faster than in previous releases.