github classgraph/classgraph classgraph-4.2.0

latest releases: classgraph-4.8.172, classgraph-4.8.171, classgraph-4.8.170...
5 years ago

(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 the java.lang.reflection.Method object for the method.
  • FieldInfo#loadClassAndGetField() -- loads the declaring class, then gets the java.lang.reflection.Field object for the field.
  • ClassInfo#getSimpleName() -- returns the class name without its package name
  • ClassInfo#hasMethodParameterAnnotation(String annotationName) -- returns true if this class has a method that has a parameter with the named annotation
  • FieldInfo#hasAnnotation(String annotationName) -- returns true if this field has the named annotation
  • MethodInfo#hasAnnotation(String annotationName) -- returns true if this method has the named annotation
  • MethodInfo#hasParameterAnnotation(String annotationName) -- returns true if this method has a parameter with the named annotation
  • MethodParameterInfo#hasAnnotation(String annotationName) -- returns true if this method parameter has the named annotation
  • MethodParameterInfo#getMethodInfo() -- get the MethodInfo object for the method with this method parameter.

(4) Performance optimization:

  • ClassInfo#loadClass() was optimized to cache the returned Class<?> value, so that repeated calls are faster (e.g. when calling MethodInfo#loadClassAndGetMethod() or FieldInfo#loadClassAndGetField() multiple times for different methods/fields in the same class)

Don't miss a new classgraph release

NewReleases is sending notifications on new releases.