Package net.bytebuddy.dynamic.loading
Enum Class ByteArrayClassLoader.PersistenceHandler
java.lang.Object
java.lang.Enum<ByteArrayClassLoader.PersistenceHandler>
net.bytebuddy.dynamic.loading.ByteArrayClassLoader.PersistenceHandler
- All Implemented Interfaces:
Serializable
,Comparable<ByteArrayClassLoader.PersistenceHandler>
,Constable
- Enclosing class:
ByteArrayClassLoader
public static enum ByteArrayClassLoader.PersistenceHandler
extends Enum<ByteArrayClassLoader.PersistenceHandler>
A persistence handler decides on whether the byte array that represents a loaded class is exposed by
the
ClassLoader.getResourceAsStream(String)
method.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
An action to define a URL that represents a class file.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The suffix of files in the Java class file format.private final boolean
true
if this persistence handler represents manifest class file storage. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
PersistenceHandler
(boolean manifest) Creates a new persistence handler. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if this persistence handler represents manifest class file storage.protected abstract byte[]
lookup
(String name, ConcurrentMap<String, byte[]> typeDefinitions) Performs a lookup of a class file by its name.protected abstract void
release
(String name, ConcurrentMap<String, byte[]> typeDefinitions) Removes the binary representation of the supplied type if this class loader is latent.protected abstract URL
url
(String resourceName, ConcurrentMap<String, byte[]> typeDefinitions) Returns a URL representing a class file.Returns the enum constant of this class with the specified name.values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
MANIFEST
The manifest persistence handler retains all class file representations and makes them accessible. -
LATENT
The latent persistence handler hides all class file representations and does not make them accessible even before they are loaded.
-
-
Field Details
-
CLASS_FILE_SUFFIX
The suffix of files in the Java class file format.- See Also:
-
manifest
private final boolean manifesttrue
if this persistence handler represents manifest class file storage.
-
-
Constructor Details
-
PersistenceHandler
private PersistenceHandler(boolean manifest) Creates a new persistence handler.- Parameters:
manifest
-true
if this persistence handler represents manifest class file storage.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
isManifest
public boolean isManifest()Checks if this persistence handler represents manifest class file storage.- Returns:
true
if this persistence handler represents manifest class file storage.
-
lookup
@MaybeNull protected abstract byte[] lookup(String name, ConcurrentMap<String, byte[]> typeDefinitions) Performs a lookup of a class file by its name.- Parameters:
name
- The name of the class to be loaded.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.- Returns:
- The byte array representing the requested class or
null
if no such class is known.
-
url
@MaybeNull protected abstract URL url(String resourceName, ConcurrentMap<String, byte[]> typeDefinitions) Returns a URL representing a class file.- Parameters:
resourceName
- The name of the requested resource.typeDefinitions
- A mapping of byte arrays by their type names.- Returns:
- A URL representing the type definition or
null
if the requested resource does not represent a class file.
-
release
Removes the binary representation of the supplied type if this class loader is latent.- Parameters:
name
- The name of the type.typeDefinitions
- A mapping of byte arrays by their type names.
-