@UsesJava7 public class SimpleInstrumentableClassLoader extends OverridingClassLoader
ClassLoader
.
Usable in tests and standalone environments.
DEFAULT_EXCLUDED_PACKAGES
parallelCapableClassLoaderAvailable
Constructor and Description |
---|
SimpleInstrumentableClassLoader(ClassLoader parent)
Create a new SimpleInstrumentableClassLoader for the given ClassLoader.
|
Modifier and Type | Method and Description |
---|---|
void |
addTransformer(ClassFileTransformer transformer)
Add a
ClassFileTransformer to be applied by this ClassLoader. |
protected byte[] |
transformIfNecessary(String name,
byte[] bytes)
Transformation hook to be implemented by subclasses.
|
isEligibleForOverriding, loadBytesForClass, loadClass, loadClass, loadClassForOverriding, openStreamForClass
excludeClass, excludePackage, isExcluded
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public SimpleInstrumentableClassLoader(ClassLoader parent)
parent
- the ClassLoader to build an instrumentable ClassLoader forpublic void addTransformer(ClassFileTransformer transformer)
ClassFileTransformer
to be applied by this ClassLoader.transformer
- the ClassFileTransformer
to registerprotected byte[] transformIfNecessary(String name, byte[] bytes)
OverridingClassLoader
The default implementation simply returns the given bytes as-is.
transformIfNecessary
in class OverridingClassLoader
name
- the fully-qualified name of the class being transformedbytes
- the raw bytes of the classnull
;
same as the input bytes if the transformation produced no changes)