Package org.jboss.modules
Interface ClassTransformer
-
- 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(java.util.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.java.nio.ByteBuffertransform(java.lang.ClassLoader loader, java.lang.String className, java.security.ProtectionDomain protectionDomain, java.nio.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
java.nio.ByteBuffer transform(java.lang.ClassLoader loader, java.lang.String className, java.security.ProtectionDomain protectionDomain, java.nio.ByteBuffer classBytes) throws java.lang.IllegalArgumentExceptionTransform 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:
java.lang.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(java.util.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)
-
-