What is the difference between Class.forName() and ClassLoader.loadClass()?
Both methods try to dynamically locate and load a java.lang.Class object corresponding to a given class name. However, their behavior differs regarding which java.lang.ClassLoader they use for class loading and whether or not the resulting Class object is initialized.
Additionally, Class.forName()‘s common form initializes the loaded class. The visible effect of this is the execution of the class’s static initializers
as well as byte code corresponding to initialization expressions of all static fields (this process occurs recursively for
all the class’s superclasses). This differs from ClassLoader.loadClass() behavior, which delays initialization until the class is used for the first time.
if it is important to process all such errors at a known point in code,
you should use a Class.forName() version that performs initialization.