Package net.bytebuddy.dynamic.loading
Enum ByteArrayClassLoader.PersistenceHandler
- java.lang.Object
-
- java.lang.Enum<ByteArrayClassLoader.PersistenceHandler>
-
- net.bytebuddy.dynamic.loading.ByteArrayClassLoader.PersistenceHandler
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ByteArrayClassLoader.PersistenceHandler>
- Enclosing class:
- ByteArrayClassLoader
public static enum ByteArrayClassLoader.PersistenceHandler extends java.lang.Enum<ByteArrayClassLoader.PersistenceHandler>
A persistence handler decides on whether the byte array that represents a loaded class is exposed by theClassLoader.getResourceAsStream(String)
method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ByteArrayClassLoader.PersistenceHandler.UrlDefinitionAction
An action to define a URL that represents a class file.
-
Enum Constant Summary
Enum Constants Enum Constant Description LATENT
The latent persistence handler hides all class file representations and does not make them accessible even before they are loaded.MANIFEST
The manifest persistence handler retains all class file representations and makes them accessible.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
CLASS_FILE_SUFFIX
The suffix of files in the Java class file format.private boolean
manifest
true
if this persistence handler represents manifest class file storage.
-
Constructor Summary
Constructors Modifier Constructor Description private
PersistenceHandler(boolean manifest)
Creates a new persistence handler.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
isManifest()
Checks if this persistence handler represents manifest class file storage.protected abstract byte[]
lookup(java.lang.String name, java.util.concurrent.ConcurrentMap<java.lang.String,byte[]> typeDefinitions)
Performs a lookup of a class file by its name.protected abstract void
release(java.lang.String name, java.util.concurrent.ConcurrentMap<java.lang.String,byte[]> typeDefinitions)
Removes the binary representation of the supplied type if this class loader is latent.protected abstract java.net.URL
url(java.lang.String resourceName, java.util.concurrent.ConcurrentMap<java.lang.String,byte[]> typeDefinitions)
Returns a URL representing a class file.static ByteArrayClassLoader.PersistenceHandler
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static ByteArrayClassLoader.PersistenceHandler[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
MANIFEST
public static final ByteArrayClassLoader.PersistenceHandler MANIFEST
The manifest persistence handler retains all class file representations and makes them accessible.
-
LATENT
public static final ByteArrayClassLoader.PersistenceHandler LATENT
The latent persistence handler hides all class file representations and does not make them accessible even before they are loaded.
-
-
Field Detail
-
CLASS_FILE_SUFFIX
private static final java.lang.String CLASS_FILE_SUFFIX
The suffix of files in the Java class file format.- See Also:
- Constant Field Values
-
manifest
private final boolean manifest
true
if this persistence handler represents manifest class file storage.
-
-
Method Detail
-
values
public static ByteArrayClassLoader.PersistenceHandler[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ByteArrayClassLoader.PersistenceHandler c : ByteArrayClassLoader.PersistenceHandler.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ByteArrayClassLoader.PersistenceHandler valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- 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
protected abstract byte[] lookup(java.lang.String name, java.util.concurrent.ConcurrentMap<java.lang.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
protected abstract java.net.URL url(java.lang.String resourceName, java.util.concurrent.ConcurrentMap<java.lang.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
protected abstract void release(java.lang.String name, java.util.concurrent.ConcurrentMap<java.lang.String,byte[]> typeDefinitions)
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.
-
-