Package net.bytebuddy.dynamic
Class ClassFileLocator.ForModule.WeaklyReferenced
- java.lang.Object
-
- java.lang.ref.Reference<T>
-
- java.lang.ref.WeakReference<java.lang.Object>
-
- net.bytebuddy.dynamic.ClassFileLocator.ForModule.WeaklyReferenced
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ClassFileLocator
- Enclosing class:
- ClassFileLocator.ForModule
public static class ClassFileLocator.ForModule.WeaklyReferenced extends java.lang.ref.WeakReference<java.lang.Object> implements ClassFileLocator
A class file locator for a Java module that only references this module weakly. If a module was garbage collected, this class file locator only returns unresolved resolutions.
Important: Even when calling
Closeable.close()on this class file locator, no underlying class loader is closed if it implements theCloseableinterface as this is typically not intended.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.ClassFileLocator
ClassFileLocator.AgentBased, ClassFileLocator.Compound, ClassFileLocator.ForClassLoader, ClassFileLocator.ForFolder, ClassFileLocator.ForJarFile, ClassFileLocator.ForModule, ClassFileLocator.ForModuleFile, ClassFileLocator.ForUrl, ClassFileLocator.NoOp, ClassFileLocator.PackageDiscriminating, ClassFileLocator.Resolution, ClassFileLocator.Simple
-
-
Field Summary
Fields Modifier and Type Field Description private inthashCodeThe represented module's hash code.-
Fields inherited from interface net.bytebuddy.dynamic.ClassFileLocator
CLASS_FILE_EXTENSION
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedWeaklyReferenced(java.lang.Object module)Creates a class file locator for a Java module that is weakly referenced.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanequals(java.lang.Object other)inthashCode()ClassFileLocator.Resolutionlocate(java.lang.String name)Locates the class file for a given type and returns the binary data of the class file.static ClassFileLocatorof(JavaModule module)Creates a class file locator for a Java module where the module is referenced weakly.
-
-
-
Method Detail
-
of
public static ClassFileLocator of(JavaModule module)
Creates a class file locator for a Java module where the module is referenced weakly. If the module is not named, the module's class loader is represented instead. Module's of the boot layer are not referenced weakly.- Parameters:
module- The Java module to represent.- Returns:
- A suitable class file locator.
-
locate
public ClassFileLocator.Resolution locate(java.lang.String name) throws java.io.IOException
Locates the class file for a given type and returns the binary data of the class file.- Specified by:
locatein interfaceClassFileLocator- Parameters:
name- The name of the type to locate a class file representation for.- Returns:
- Any binary representation of the type which might be illegal.
- Throws:
java.io.IOException- If reading a class file causes an error.
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
-