Package org.jboss.modules

# Class ClassDefiner

java.lang.Object
org.jboss.modules.ClassDefiner

public final class ClassDefiner extends Object
A hook for frameworks which need to define additional classes to a module's class loader.

## Method Summary

Modifier and Type
Method
Description
`Class<?>`
`defineClass(Class<?> originalClass, String className, byte[] classBytes)`
Define a class using the module and protection domain of an existing class.
`Class<?>`
`defineClass(Class<?> originalClass, String className, byte[] classBytes, int off, int len)`
Define a class using the module and protection domain of an existing class.
`Class<?>`
`defineClass(Class<?> originalClass, String className, ByteBuffer classBytes)`
Define a class using the module and protection domain of an existing class.
`Class<?>`
`defineClass(Class<?> originalClass, String className, ProtectionDomain protectionDomain, byte[] classBytes)`
Define a class using the module of an existing class.
`Class<?>`
`defineClass(Class<?> originalClass, String className, ProtectionDomain protectionDomain, byte[] classBytes, int off, int len)`
Define a class using the module of an existing class.
`Class<?>`
`defineClass(Class<?> originalClass, String className, ProtectionDomain protectionDomain, ByteBuffer classBytes)`
Define a class using the module of an existing class.
`Class<?>`
`defineClass(Module module, String className, ProtectionDomain protectionDomain, byte[] classBytes)`
Define a class.
`Class<?>`
`defineClass(Module module, String className, ProtectionDomain protectionDomain, byte[] classBytes, int off, int len)`
Define a class.
`Class<?>`
`defineClass(Module module, String className, ProtectionDomain protectionDomain, ByteBuffer classBytes)`
Define a class.
`static ClassDefiner`
`getInstance()`
Get the class definer instance.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### defineClass

public Class<?> defineClass(Class<?> originalClass, String className, ByteBuffer classBytes)
Define a class using the module and protection domain of an existing class.

Parameters:
  `originalClass` - the existing class (must not be `null`)
  `className` - the new class name (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
Returns:
  the defined class (not `null`)

### defineClass

public Class<?> defineClass(Class<?> originalClass, String className, byte[] classBytes, int off, int len)
Define a class using the module and protection domain of an existing class.

Parameters:
  `originalClass` - the existing class (must not be `null`)
  `className` - the new class name (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
  `off` - the offset into the `classBytes` array
  `len` - the number of bytes to use from the `classBytes` array
Returns:
  the defined class (not `null`)

### defineClass

public Class<?> defineClass(Class<?> originalClass, String className, byte[] classBytes)
Define a class using the module and protection domain of an existing class.

Parameters:
  `originalClass` - the existing class (must not be `null`)
  `className` - the new class name (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
Returns:
  the defined class (not `null`)

### defineClass

public Class<?> defineClass(Class<?> originalClass, String className, ProtectionDomain protectionDomain, ByteBuffer classBytes)
Define a class using the module of an existing class.

Parameters:
  `originalClass` - the existing class (must not be `null`)
  `className` - the new class name (must not be `null`)
  `protectionDomain` - the protection domain of the new class (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
Returns:
  the defined class (not `null`)

### defineClass

public Class<?> defineClass(Class<?> originalClass, String className, ProtectionDomain protectionDomain, byte[] classBytes, int off, int len)
Define a class using the module of an existing class.

Parameters:
  `originalClass` - the existing class (must not be `null`)
  `className` - the new class name (must not be `null`)
  `protectionDomain` - the protection domain of the new class (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
  `off` - the offset into the `classBytes` array
  `len` - the number of bytes to use from the `classBytes` array
Returns:
  the defined class (not `null`)

### defineClass

public Class<?> defineClass(Class<?> originalClass, String className, ProtectionDomain protectionDomain, byte[] classBytes)
Define a class using the module of an existing class.

Parameters:
  `originalClass` - the existing class (must not be `null`)
  `className` - the new class name (must not be `null`)
  `protectionDomain` - the protection domain of the new class (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
Returns:
  the defined class (not `null`)

### defineClass

public Class<?> defineClass(Module module, String className, ProtectionDomain protectionDomain, ByteBuffer classBytes)
Define a class.

Parameters:
  `module` - the module to define the class to (must not be `null`)
  `className` - the new class name (must not be `null`)
  `protectionDomain` - the protection domain of the new class (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
Returns:
  the defined class (not `null`)

### defineClass

public Class<?> defineClass(Module module, String className, ProtectionDomain protectionDomain, byte[] classBytes, int off, int len)
Define a class.

Parameters:
  `module` - the module to define the class to (must not be `null`)
  `className` - the new class name (must not be `null`)
  `protectionDomain` - the protection domain of the new class (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
  `off` - the offset into the `classBytes` array
  `len` - the number of bytes to use from the `classBytes` array
Returns:
  the defined class (not `null`)

### defineClass

public Class<?> defineClass(Module module, String className, ProtectionDomain protectionDomain, byte[] classBytes)
Define a class.

Parameters:
  `module` - the module to define the class to (must not be `null`)
  `className` - the new class name (must not be `null`)
  `protectionDomain` - the protection domain of the new class (must not be `null`)
  `classBytes` - the new class bytes (must not be `null`)
Returns:
  the defined class (not `null`)

### getInstance

public static ClassDefiner getInstance()
Get the class definer instance. The caller must have the `createClassLoader` `RuntimePermission`.

Returns:
  the singleton class definer instance (not `null`)