Package org.springframework.cglib.core

# Class ClassLoaderAwareGeneratorStrategy

java.lang.Object
org.springframework.cglib.core.DefaultGeneratorStrategy
org.springframework.cglib.core.ClassLoaderAwareGeneratorStrategy

All Implemented Interfaces:
  `GeneratorStrategy`

public class ClassLoaderAwareGeneratorStrategy extends DefaultGeneratorStrategy
CGLIB GeneratorStrategy variant which exposes the application ClassLoader as current thread context ClassLoader for the time of class generation. The ASM ClassWriter in Spring's ASM variant will pick it up when doing common superclass resolution.

Since:
  5.2
Author:
  Juergen Hoeller

## Field Summary

### Fields inherited from class org.springframework.cglib.core.DefaultGeneratorStrategy

`INSTANCE`

## Constructor Summary

Constructors
Constructor
Description
`ClassLoaderAwareGeneratorStrategy(ClassLoader classLoader)`
Create a default GeneratorStrategy, exposing the given ClassLoader.
`ClassLoaderAwareGeneratorStrategy(ClassLoader classLoader, GeneratorStrategy delegate)`
Create a decorator for the given GeneratorStrategy delegate, exposing the given ClassLoader.

## Method Summary

Modifier and Type
Method
Description
`byte[]`
`generate(ClassGenerator cg)`
Generate the class.

### Methods inherited from class org.springframework.cglib.core.DefaultGeneratorStrategy

`getClassVisitor, getClassWriter, transform, transform`

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

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

### Methods inherited from interface org.springframework.cglib.core.GeneratorStrategy

`equals`

## Constructor Details

### ClassLoaderAwareGeneratorStrategy

public ClassLoaderAwareGeneratorStrategy(ClassLoader classLoader)
Create a default GeneratorStrategy, exposing the given ClassLoader.

Parameters:
  `classLoader` - the ClassLoader to expose as current thread context ClassLoader

### ClassLoaderAwareGeneratorStrategy

public ClassLoaderAwareGeneratorStrategy(ClassLoader classLoader, GeneratorStrategy delegate)
Create a decorator for the given GeneratorStrategy delegate, exposing the given ClassLoader.

Parameters:
  `classLoader` - the ClassLoader to expose as current thread context ClassLoader
Since:
  6.2

## Method Details

### generate

public byte[] generate(ClassGenerator cg) throws Exception
Description copied from interface: `GeneratorStrategy`
Generate the class.

Specified by:
  `generate` in interface `GeneratorStrategy`
Overrides:
  `generate` in class `DefaultGeneratorStrategy`
Parameters:
  `cg` - a class generator on which you can call `ClassGenerator.generateClass(org.springframework.asm.ClassVisitor)`
Returns:
  a byte array containing the bits of a valid Class
Throws:
  `Exception`