(1) Behavioral change for ClassInfo#getMethodInfo()
and classInfo#getFieldInfo()
methods (hence the version bump to 4.2.x):
For greater consistency with the Java reflection API, the following methods now return methods/fields declared in the class represented by the ClassInfo
object as well as the methods/fields declared by the class' implemented interfaces and superclasses:
MethodInfoList ClassInfo#getMethodInfo(String methodName)
MethodInfoList ClassInfo#getMethodInfo()
MethodInfoList ClassInfo#getConstructorInfo()
MethodInfoList ClassInfo#getMethodAndConstructorInfo()
FieldInfo ClassInfo#getFieldInfo(String fieldName)
FieldInfoList ClassInfo#getFieldInfo()
Formerly the behavior was to only return methods/fields declared in the class, but not by its interfaces or superclasses. The following new methods implement this old behavior:
MethodInfoList ClassInfo#getDeclaredMethodInfo(String methodName)
MethodInfoList ClassInfo#getDeclaredMethodInfo()
MethodInfoList ClassInfo#getDeclaredConstructorInfo()
MethodInfoList ClassInfo#getDeclaredMethodAndConstructorInfo()
FieldInfo ClassInfo#getDeclaredFieldInfo(String fieldName)
FieldInfoList ClassInfo#getDeclaredFieldInfo()
(2) Bugfix:
TypeSignature#loadClass()
was fixed for primitive types (int.class
etc.) -- this would throw an exception before.
(3) The following convenience methods were added:
MethodInfo#loadClassAndGetMethod()
-- loads the declaring class, then gets thejava.lang.reflection.Method
object for the method.FieldInfo#loadClassAndGetField()
-- loads the declaring class, then gets thejava.lang.reflection.Field
object for the field.ClassInfo#getSimpleName()
-- returns the class name without its package nameClassInfo#hasMethodParameterAnnotation(String annotationName)
-- returns true if this class has a method that has a parameter with the named annotationFieldInfo#hasAnnotation(String annotationName)
-- returns true if this field has the named annotationMethodInfo#hasAnnotation(String annotationName)
-- returns true if this method has the named annotationMethodInfo#hasParameterAnnotation(String annotationName)
-- returns true if this method has a parameter with the named annotationMethodParameterInfo#hasAnnotation(String annotationName)
-- returns true if this method parameter has the named annotationMethodParameterInfo#getMethodInfo()
-- get theMethodInfo
object for the method with this method parameter.
(4) Performance optimization:
ClassInfo#loadClass()
was optimized to cache the returnedClass<?>
value, so that repeated calls are faster (e.g. when callingMethodInfo#loadClassAndGetMethod()
orFieldInfo#loadClassAndGetField()
multiple times for different methods/fields in the same class)