Package hudson.util
Class CachingClassLoader
java.lang.Object
java.lang.ClassLoader
hudson.util.DelegatingClassLoader
hudson.util.CachingClassLoader
- Direct Known Subclasses:
PluginManager.UberClassLoader
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public class CachingClassLoader
extends DelegatingClassLoader
ClassLoader with internal caching of class loading results.
Caches both successful and failed class lookups to avoid redundant delegation and repeated class resolution attempts. Designed for performance optimization in systems that repeatedly query class presence (e.g., plugin environments, reflective loading, optional dependencies).
Useful for classloaders that have heavy-weight loadClass() implementations- Author:
- Dmytro Ukhlov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected Class
<?> Parent-first delegation without synchronizing onClassLoader.getClassLoadingLock(String)
.Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
CachingClassLoader
-
-
Method Details
-
loadClass
Description copied from class:DelegatingClassLoader
Parent-first delegation without synchronizing onClassLoader.getClassLoadingLock(String)
. This prevents creation/retention of per-name lock objects in a loader that does not define classes. The defining loader downstream still serializes class definition as required.- Overrides:
loadClass
in classDelegatingClassLoader
- Parameters:
name
- The binary name of the classresolve
- Iftrue
then resolve the class- Returns:
- The resulting
Class
object - Throws:
ClassNotFoundException
- If the class could not be found
-
clearCacheMisses
public void clearCacheMisses()
-