-
- All Known Implementing Classes:
JLIClassTransformer
public interface ClassTransformerA class file transformer which operates on byte buffers.
-
-
Field Summary
Fields Modifier and Type Field Description static ClassTransformerIDENTITYThe identity transformation, which does not modify the class bytes at all.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static ClassTransformerallOf(Collection<? extends ClassTransformer> transformers)Get a new transformer which applies all the transformations in the given collection.default ClassTransformerandThen(ClassTransformer other)Get a new transformer which applies this transformation followed by another transformation.ByteBuffertransform(ClassLoader loader, String className, ProtectionDomain protectionDomain, ByteBuffer classBytes)Transform the bytes of a class.
-
-
-
Field Detail
-
IDENTITY
static final ClassTransformer IDENTITY
The identity transformation, which does not modify the class bytes at all.
-
-
Method Detail
-
transform
ByteBuffer transform(ClassLoader loader, String className, ProtectionDomain protectionDomain, ByteBuffer classBytes) throws IllegalArgumentException
Transform the bytes of a class. The position and limit of both the passed-in and returned buffers must mark the start and end of the class bytes.- Parameters:
loader- the class loader of the class being transformedclassName- the internal name of the class being transformed (notnull)protectionDomain- the protection domain of the class, if anyclassBytes- the class bytes being transformed (notnull; may be a direct or heap buffer)- Returns:
- the transformation result (may be a direct or heap buffer)
- Throws:
IllegalArgumentException- if the class could not be transformed for some reason
-
andThen
default ClassTransformer andThen(ClassTransformer other)
Get a new transformer which applies this transformation followed by another transformation.- Parameters:
other- the other transformation (must not benull)- Returns:
- the new transformer (not
null)
-
allOf
static ClassTransformer allOf(Collection<? extends ClassTransformer> transformers)
Get a new transformer which applies all the transformations in the given collection. The collection should either be immutable or safe for concurrent iteration. A synchronized collection is insufficiently thread-safe.- Parameters:
transformers- the transformer collection (must not benull)- Returns:
- the new transformer (not
null)
-
-