public final class ClassUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> java.lang.Class<? extends T> |
forName(java.lang.String className,
java.lang.Class<T> expectedClass,
java.lang.ClassLoader classLoader)
Deprecated.
use
forName(String, Class, ClassLoaderStrategy, ClassLoader), which also
lets the caller fall back to the thread context classloader |
static <T> java.lang.Class<? extends T> |
forName(java.lang.String className,
java.lang.Class<T> expectedClass,
ClassLoaderStrategy strategy,
java.lang.ClassLoader driverClassLoader)
Loads a class named by a connection property and validates that it is assignable to the
expected type.
|
public static <T> java.lang.Class<? extends T> forName(java.lang.String className,
java.lang.Class<T> expectedClass,
ClassLoaderStrategy strategy,
java.lang.ClassLoader driverClassLoader)
throws java.lang.ClassNotFoundException
initialize=false so that its static
initialiser does not run until the type check has passed.
The classloaders to try, and their order, come from strategy. The first classloader
that resolves the name wins; a ClassNotFoundException from one classloader falls through
to the next. A class that resolves but is not a subtype of expectedClass fails fast with
a ClassCastException rather than falling through.
T - the expected typeclassName - the name of the class to loadexpectedClass - the expected superclass or interfacestrategy - the order in which to try the classloadersdriverClassLoader - the driver's own classloaderjava.lang.ClassNotFoundException - if none of the classloaders can find the class@Deprecated
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
forName(String, Class, ClassLoaderStrategy, ClassLoader), which also
lets the caller fall back to the thread context classloadernull classLoader means the bootstrap classloader, matching
Class.forName(String, boolean, ClassLoader).T - the expected typeclassName - the name of the class to loadexpectedClass - the expected superclass or interfaceclassLoader - the classloader to usejava.lang.ClassNotFoundException - if the class cannot be foundCopyright © 2026 PostgreSQL Global Development Group. All rights reserved.