Operates on classes without using reflection. This class handles invalid null inputs as best it can. Each method documents its behavior in more detail. The notion of a canonical name includes the human-readable name for the type, for example int[]. The non-cano
| 49 | * @since 2.0 |
| 50 | */ |
| 51 | public class ClassUtils { |
| 52 | |
| 53 | /** |
| 54 | * Enumerates inclusivity literals for {@link #hierarchy(Class, Interfaces)}. |
| 55 | * |
| 56 | * @since 3.2 |
| 57 | */ |
| 58 | public enum Interfaces { |
| 59 | |
| 60 | /** Includes interfaces. */ |
| 61 | INCLUDE, |
| 62 | |
| 63 | /** Excludes interfaces. */ |
| 64 | EXCLUDE |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * The JLS-specified maximum class name length {@value}. |
| 69 | * |
| 70 | * @see Class#forName(String, boolean, ClassLoader) |
| 71 | * @see <a href="https://docs.oracle.com/javase/specs/jvms/se25/html/jvms-4.html#jvms-4.4.1">JVM: Array dimension limits in JVM Specification CONSTANT_Class_info</a> |
| 72 | * @see <a href="https://docs.oracle.com/javase/specs/jls/se25/html/jls-6.html#jls-6.7">JLS: Fully Qualified Names and Canonical Names</a> |
| 73 | * @see <a href="https://docs.oracle.com/javase/specs/jls/se25/html/jls-13.html#jls-13.1">JLS: The Form of a Binary</a> |
| 74 | */ |
| 75 | private static final int MAX_CLASS_NAME_LENGTH = 65535; |
| 76 | |
| 77 | /** |
| 78 | * The JVM-specified {@code CONSTANT_Class_info} structure defines an array type descriptor is valid only if it represents {@value} or fewer dimensions. |
| 79 | * |
| 80 | * @see Class#forName(String, boolean, ClassLoader) |
| 81 | * @see <a href="https://docs.oracle.com/javase/specs/jvms/se25/html/jvms-4.html#jvms-4.4.1">JVM: Array dimension limits in JVM Specification CONSTANT_Class_info</a> |
| 82 | * @see <a href="https://docs.oracle.com/javase/specs/jls/se25/html/jls-6.html#jls-6.7">JLS: Fully Qualified Names and Canonical Names</a> |
| 83 | * @see <a href="https://docs.oracle.com/javase/specs/jls/se25/html/jls-13.html#jls-13.1">JLS: The Form of a Binary</a> |
| 84 | */ |
| 85 | private static final int MAX_JVM_ARRAY_DIMENSION = 255; |
| 86 | |
| 87 | /** |
| 88 | * The maximum number of array dimensions. |
| 89 | */ |
| 90 | private static final int MAX_DIMENSIONS = 255; |
| 91 | |
| 92 | private static final Comparator<Class<?>> COMPARATOR = (o1, o2) -> Objects.compare(getName(o1), getName(o2), String::compareTo); |
| 93 | |
| 94 | /** |
| 95 | * The package separator character: {@code '.' == {@value}}. |
| 96 | */ |
| 97 | public static final char PACKAGE_SEPARATOR_CHAR = '.'; |
| 98 | |
| 99 | /** |
| 100 | * The package separator String: {@code "."}. |
| 101 | */ |
| 102 | public static final String PACKAGE_SEPARATOR = String.valueOf(PACKAGE_SEPARATOR_CHAR); |
| 103 | |
| 104 | /** |
| 105 | * The inner class separator character: {@code '$' == {@value}}. |
| 106 | */ |
| 107 | public static final char INNER_CLASS_SEPARATOR_CHAR = '$'; |
| 108 |
nothing calls this directly
no test coverage detected
searching dependent graphs…