Package org.jboss.modules
Interface ClassTransformer
- All Known Implementing Classes:
JLIClassTransformer
public interface ClassTransformer
A class file transformer which operates on byte buffers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClassTransformer
The identity transformation, which does not modify the class bytes at all. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassTransformer
allOf
(Collection<? extends ClassTransformer> transformers) Get a new transformer which applies all the transformations in the given collection.default ClassTransformer
andThen
(ClassTransformer other) Get a new transformer which applies this transformation followed by another transformation.transform
(ClassLoader loader, String className, ProtectionDomain protectionDomain, ByteBuffer classBytes) Transform the bytes of a class.
-
Field Details
-
IDENTITY
The identity transformation, which does not modify the class bytes at all.
-
-
Method Details
-
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
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
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
)
-