public static class ClassFileLocator.ForClassLoader.WeaklyReferenced extends WeakReference<ClassLoader> implements ClassFileLocator
A class file locator that queries a class loader for binary representations of class files. The class loader is only weakly referenced.
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.
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.Simple
CLASS_FILE_EXTENSION
Modifier | Constructor and Description |
---|---|
protected |
WeaklyReferenced(ClassLoader classLoader)
Creates a class file locator for a class loader that is weakly referenced.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
equals(Object other) |
int |
hashCode() |
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.
|
protected WeaklyReferenced(ClassLoader classLoader)
classLoader
- The class loader to represent.public static ClassFileLocator of(@MaybeNull ClassLoader classLoader)
classLoader
- The class loader to be used. If this class loader represents the bootstrap class
loader which is represented by the null
value, this system class loader
is used instead.public ClassFileLocator.Resolution locate(String name) throws IOException
locate
in interface ClassFileLocator
name
- 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 Closeable
close
in interface AutoCloseable
public boolean equals(@MaybeNull Object other)
Copyright © 2014–2024. All rights reserved.