Changed behavior of ClassInfo#toString()
to include modifiers (hence version bump to 2.8.x); added class containment info:
(1) ClassInfo#toString()
now returns the full name of the class with modifiers, e.g. public class com.xyz.Widget
or private @interface com.xyz.MyAnnotation
, rather than just the class name. The class name can still be obtained with ClassInfo#getClassName()
. This is not really an API change, but it is a behavioral change for anyone relying on ClassInfo#toString()
, so the version number was bumped to 2.8.x. The class modifiers can also now be obtained by calling ClassInfo#getClassModifiers()
.
(2) Added the following methods to detect and work with class containment (inner classes (anonymous or not), anonymous inner classes, and outer classes):
ClassInfo#isInnerClass()
returns true for both inner and anonymous inner classes.ClassInfo#isAnonymousInnerClass()
returns true for anonymous inner classes.ClassInfo#isOuterClass()
returns true for classes containing inner and/or anonymous inner classes.ClassInfo#getOuterClasses()
returns the containing outer classes, if this is an inner class.ClassInfo#getOuterClassNames()
returns the names of containing outer classes, if this is an inner class.ClassInfo#getInnerClasses()
returns inner classes, if this is an outer class.ClassInfo#getInnerClassNames()
returns inner class names, if this is an outer class.ClassInfo#getFullyQualifiedContainingMethodName()
returns, for anonymous inner classes, the name of the innermost of the outer containing classes, followed by.
, followed by the name of the method that created the anonymous inner class. If the method that created the anonymous inner class was a constructor, the method name part of the returned string will be<init>
. If the anonymous inner class was created by a field initializer or static class initializer block, the method name part of the returned string will be<clinit>
.