类 OverridingClassLoader
- java.lang.Object
- java.lang.ClassLoader
- org.springframework.core.DecoratingClassLoader
- org.springframework.core.OverridingClassLoader
 
 
 
- public class OverridingClassLoader extends DecoratingClassLoader - ClassLoaderthat does not always delegate to the parent loader as normal class loaders do. This enables, for example, instrumentation to be forced in the overriding ClassLoader, or a "throwaway" class loading behavior where selected application classes are temporarily loaded in the overriding- ClassLoaderfor introspection purposes before eventually loading an instrumented version of the class in the given parent- ClassLoader.- 从以下版本开始:
- 2.0.1
- 作者:
- Rod Johnson, Juergen Hoeller
 
- 字段概要- 字段 - 修饰符和类型 - 字段 - 说明 - static String[]- DEFAULT_EXCLUDED_PACKAGESPackages that are excluded by default.
 - 构造器概要- 构造器 - 构造器 - 说明 - OverridingClassLoader(ClassLoader parent)Create a new OverridingClassLoader for the given ClassLoader.- OverridingClassLoader(ClassLoader parent, ClassLoader overrideDelegate)Create a new OverridingClassLoader for the given ClassLoader.
 - 方法概要- 所有方法 实例方法 具体方法 - 修饰符和类型 - 方法 - 说明 - protected boolean- isEligibleForOverriding(String className)Determine whether the specified class is eligible for overriding by this class loader.- protected byte[]- loadBytesForClass(String name)Load the defining bytes for the given class, to be turned into a Class object through a- ClassLoader.defineClass(byte[], int, int)call.- Class<?>- loadClass(String name)- protected Class<?>- loadClass(String name, boolean resolve)- protected Class<?>- loadClassForOverriding(String name)Load the specified class for overriding purposes in this ClassLoader.- protected InputStream- openStreamForClass(String name)Open an InputStream for the specified class.- protected byte[]- transformIfNecessary(String name, byte[] bytes)Transformation hook to be implemented by subclasses.- 从类继承的方法 org.springframework.core.DecoratingClassLoader- excludeClass, excludePackage, isExcluded
 - 从类继承的方法 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, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
 
- 字段详细资料- DEFAULT_EXCLUDED_PACKAGES- public static final String[] DEFAULT_EXCLUDED_PACKAGES Packages that are excluded by default.
 
 - 构造器详细资料- OverridingClassLoader- public OverridingClassLoader(@Nullable ClassLoader parent) Create a new OverridingClassLoader for the given ClassLoader.- 参数:
- parent- the ClassLoader to build an overriding ClassLoader for
 
 - OverridingClassLoader- public OverridingClassLoader(@Nullable ClassLoader parent, @Nullable ClassLoader overrideDelegate) Create a new OverridingClassLoader for the given ClassLoader.- 参数:
- parent- the ClassLoader to build an overriding ClassLoader for
- overrideDelegate- the ClassLoader to delegate to for overriding
- 从以下版本开始:
- 4.3
 
 
 - 方法详细资料- loadClass- public Class<?> loadClass(String name) throws ClassNotFoundException - 覆盖:
- loadClass在类中- ClassLoader
- 抛出:
- ClassNotFoundException
 
 - loadClass- protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException - 覆盖:
- loadClass在类中- ClassLoader
- 抛出:
- ClassNotFoundException
 
 - isEligibleForOverriding- protected boolean isEligibleForOverriding(String className) Determine whether the specified class is eligible for overriding by this class loader.- 参数:
- className- the class name to check
- 返回:
- whether the specified class is eligible
- 另请参阅:
- DecoratingClassLoader.isExcluded(java.lang.String)
 
 - loadClassForOverriding- @Nullable protected Class<?> loadClassForOverriding(String name) throws ClassNotFoundException Load the specified class for overriding purposes in this ClassLoader.- The default implementation delegates to - ClassLoader.findLoadedClass(java.lang.String),- loadBytesForClass(java.lang.String)and- ClassLoader.defineClass(byte[], int, int).- 参数:
- name- the name of the class
- 返回:
- the Class object, or nullif no class defined for that name
- 抛出:
- ClassNotFoundException- if the class for the given name couldn't be loaded
 
 - loadBytesForClass- @Nullable protected byte[] loadBytesForClass(String name) throws ClassNotFoundException Load the defining bytes for the given class, to be turned into a Class object through a- ClassLoader.defineClass(byte[], int, int)call.- The default implementation delegates to - openStreamForClass(java.lang.String)and- transformIfNecessary(java.lang.String, byte[]).- 参数:
- name- the name of the class
- 返回:
- the byte content (with transformers already applied), or nullif no class defined for that name
- 抛出:
- ClassNotFoundException- if the class for the given name couldn't be loaded
 
 - openStreamForClass- @Nullable protected InputStream openStreamForClass(String name) Open an InputStream for the specified class.- The default implementation loads a standard class file through the parent ClassLoader's - getResourceAsStreammethod.- 参数:
- name- the name of the class
- 返回:
- the InputStream containing the byte code for the specified class
 
 - transformIfNecessary- protected byte[] transformIfNecessary(String name, byte[] bytes) Transformation hook to be implemented by subclasses.- The default implementation simply returns the given bytes as-is. - 参数:
- name- the fully-qualified name of the class being transformed
- bytes- the raw bytes of the class
- 返回:
- the transformed bytes (never null; same as the input bytes if the transformation produced no changes)