Class ClassUtils


  • public final class ClassUtils
    extends java.lang.Object
    Utility class for safe class loading operations.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.lang.Class<? extends T> forName​(java.lang.String className, java.lang.Class<T> expectedClass, java.lang.ClassLoader classLoader)
      Safely loads a class using the three-parameter Class.forName with initialize=false and validates it's assignable to the expected type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • forName

        public static <T> java.lang.Class<? extends T> forName​(java.lang.String className,
                                                               java.lang.Class<T> expectedClass,
                                                               java.lang.ClassLoader classLoader)
                                                        throws java.lang.ClassNotFoundException
        Safely loads a class using the three-parameter Class.forName with initialize=false and validates it's assignable to the expected type.
        Type Parameters:
        T - the expected type
        Parameters:
        className - the name of the class to load
        expectedClass - the expected superclass or interface
        classLoader - the class loader to use
        Returns:
        the loaded class as a subclass of the expected type
        Throws:
        java.lang.ClassNotFoundException - if the class cannot be found