public class GeneratorContext
extends Object
A context shared across generations of a class and its inner classes.
| Constructor and description |
|---|
GeneratorContext(CompileUnit compileUnit)Creates a new generator context for the given compile unit. |
GeneratorContext(CompileUnit compileUnit, int innerClassOffset)Creates a new generator context with a custom inner class index offset. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static String |
encodeAsValidClassName(String name)Encodes a name to be a valid Java class name by replacing special characters with underscores. |
|
public CompileUnit |
getCompileUnit()Returns the compile unit associated with this context. |
|
public String |
getNextClosureInnerName(ClassNode owner, ClassNode enclosingClass, MethodNode enclosingMethod)Generates the next unique closure inner class name. |
|
public String |
getNextConstructorReferenceSyntheticMethodName(MethodNode enclosingMethodNode)Generates a unique synthetic method name for a constructor reference. |
|
public int |
getNextInnerClassIdx()Returns and increments the inner class index for generating unique inner class names. |
|
public String |
getNextLambdaInnerName(ClassNode owner, ClassNode enclosingClass, MethodNode enclosingMethod)Generates the next unique lambda inner class name. |
Creates a new generator context for the given compile unit.
compileUnit - the compile unit this context is associated withCreates a new generator context with a custom inner class index offset.
compileUnit - the compile unit this context is associated withinnerClassOffset - the starting index for inner class namingEncodes a name to be a valid Java class name by replacing special characters with underscores. Characters such as operators, punctuation, and other invalid class name characters are encoded. The special names "module-info" and "package-info" are preserved unchanged.
name - the name to encodeReturns the compile unit associated with this context.
Generates the next unique closure inner class name.
owner - the owner class (currently unused but kept for API compatibility)enclosingClass - the class that encloses the closureenclosingMethod - the method that encloses the closure, or null if at class levelGenerates a unique synthetic method name for a constructor reference.
enclosingMethodNode - the method that contains the constructor reference, or null if at class levelReturns and increments the inner class index for generating unique inner class names.
Generates the next unique lambda inner class name.
owner - the owner class (currently unused but kept for API compatibility)enclosingClass - the class that encloses the lambdaenclosingMethod - the method that encloses the lambda, or null if at class levelCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.