@HashCodeAndEqualsPlugin.Enhance public static class ClassFileLocator.ForClassLoader extends Object implements ClassFileLocator
A class file locator that queries a class loader for binary representations of class files.
 Important: Even when calling Closeable.close() on this class file locator, no underlying
 class loader is closed if it implements the Closeable interface as this is typically not intended.
 
| Modifier and Type | Class and Description | 
|---|---|
| protected static class  | ClassFileLocator.ForClassLoader.BootLoaderProxyCreationActionA privileged action for creating a proxy class loader for the boot class loader. | 
| static class  | ClassFileLocator.ForClassLoader.WeaklyReferenced
 A class file locator that queries a class loader for binary representations of class files. | 
ClassFileLocator.Compound, ClassFileLocator.Filtering, ClassFileLocator.ForClassLoader, ClassFileLocator.ForFolder, ClassFileLocator.ForInstrumentation, ClassFileLocator.ForJarFile, ClassFileLocator.ForModule, ClassFileLocator.ForModuleFile, ClassFileLocator.ForUrl, ClassFileLocator.NoOp, ClassFileLocator.PackageDiscriminating, ClassFileLocator.Resolution, ClassFileLocator.SimpleCLASS_FILE_EXTENSION| Modifier | Constructor and Description | 
|---|---|
| protected  | ForClassLoader(ClassLoader classLoader)Creates a new class file locator for the given class loader. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close() | 
| protected static ClassFileLocator.Resolution | locate(ClassLoader classLoader,
      String name)Locates the class file for the supplied type by requesting a resource from the class loader. | 
| ClassFileLocator.Resolution | locate(String name)Locates the class file for a given type and returns the binary data of the class file. | 
| static ClassFileLocator | of(ClassLoader classLoader)Creates a class file locator for a given class loader. | 
| static ClassFileLocator | ofBootLoader()Creates a class file locator that queries the boot loader. | 
| static ClassFileLocator | ofPlatformLoader()Creates a class file locator that queries the plaform class loader or the extension class loader if the
 current VM is not at least of version 9. | 
| static ClassFileLocator | ofSystemLoader()Creates a class file locator that queries the system class loader. | 
| static Map<Class<?>,byte[]> | read(Class<?>... type)Attempts to create a binary representation of several loaded types by requesting
 data from their respective  ClassLoaders. | 
| static byte[] | read(Class<?> type)Attempts to create a binary representation of a loaded type by requesting data from its
  ClassLoader. | 
| static Map<Class<?>,byte[]> | read(Collection<? extends Class<?>> types)Attempts to create a binary representation of several loaded types by requesting
 data from their respective  ClassLoaders. | 
| static Map<String,byte[]> | readToNames(Class<?>... type)Attempts to create a binary representation of several loaded types by requesting
 data from their respective  ClassLoaders. | 
| static Map<String,byte[]> | readToNames(Collection<? extends Class<?>> types)Attempts to create a binary representation of several loaded types by requesting
 data from their respective  ClassLoaders. | 
protected ForClassLoader(ClassLoader classLoader)
classLoader - The class loader to query which must not be the bootstrap class loader, i.e. null.public static ClassFileLocator ofSystemLoader()
public static ClassFileLocator ofPlatformLoader()
public static ClassFileLocator ofBootLoader()
public static ClassFileLocator of(@MaybeNull ClassLoader classLoader)
classLoader - The class loader to be used which might be null to represent the bootstrap loader.public static byte[] read(Class<?> type)
ClassLoader.type - The type of interest.public static Map<Class<?>,byte[]> read(Class<?>... type)
ClassLoaders.type - The types of interest.public static Map<Class<?>,byte[]> read(Collection<? extends Class<?>> types)
ClassLoaders.types - The types of interest.public static Map<String,byte[]> readToNames(Class<?>... type)
ClassLoaders.type - The types of interest.public static Map<String,byte[]> readToNames(Collection<? extends Class<?>> types)
ClassLoaders.types - The types of interest.public ClassFileLocator.Resolution locate(String name) throws IOException
locate in interface ClassFileLocatorname - The name of the type to locate a class file representation for.IOException - If reading a class file causes an error.public void close()
close in interface Closeableclose in interface AutoCloseableprotected static ClassFileLocator.Resolution locate(ClassLoader classLoader, String name) throws IOException
classLoader - The class loader to query.name - The name of the type for which to locate a class file.IOException - If reading the class file causes an exception.Copyright © 2014–2024. All rights reserved.