Top Description Fields Methods
org.jboss.modules

public Interface ClassTransformer

Known Direct Implementers
org.jboss.modules.JLIClassTransformer
Imports
java.nio.ByteBuffer, java.security.ProtectionDomain, java.util.Collection

A class file transformer which operates on byte buffers.

Field Summary

Modifier and TypeField and Description
public static final ClassTransformer
IDENTITY

The identity transformation, which does not modify the class bytes at all.

Method Summary

Modifier and TypeMethod and Description
public static ClassTransformer

Returns:

the new transformer (not null)
allOf
(Collection<? extends ClassTransformer>
the transformer collection (must not be null)
transformers
)

Get a new transformer which applies all the transformations in the given collection.

public default ClassTransformer

Returns:

the new transformer (not null)
andThen
(ClassTransformer
the other transformation (must not be null)
other
)

Get a new transformer which applies this transformation followed by another transformation.

public ByteBuffer

Returns:

the transformation result (may be a direct or heap buffer)
transform
(ClassLoader
the class loader of the class being transformed
loader
,
String
the internal name of the class being transformed (not null)
className
,
ProtectionDomain
the protection domain of the class, if any
protectionDomain
,
ByteBuffer
the class bytes being transformed (not null; may be a direct or heap buffer)
classBytes
)

Transform the bytes of a class.

Field Detail

IDENTITYback to summary
public static final ClassTransformer IDENTITY

The identity transformation, which does not modify the class bytes at all.

Method Detail

allOfback to summary
public 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:Collection<? extends ClassTransformer>

the transformer collection (must not be null)

Returns:ClassTransformer

the new transformer (not null)

andThenback to summary
public default ClassTransformer andThen(ClassTransformer other)

Get a new transformer which applies this transformation followed by another transformation.

Parameters
other:ClassTransformer

the other transformation (must not be null)

Returns:ClassTransformer

the new transformer (not null)

transformback to summary
public 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:ClassLoader

the class loader of the class being transformed

className:String

the internal name of the class being transformed (not null)

protectionDomain:ProtectionDomain

the protection domain of the class, if any

classBytes:ByteBuffer

the class bytes being transformed (not null; may be a direct or heap buffer)

Returns:ByteBuffer

the transformation result (may be a direct or heap buffer)

Exceptions
IllegalArgumentException:
if the class could not be transformed for some reason