# Package org.codehaus.groovy.classgen

package org.codehaus.groovy.classgen
Provides classes for generating Java bytecode from Groovy Abstract Syntax Trees (AST).

This package contains the core class generation infrastructure that transforms Groovy's AST representation into executable Java bytecode using the ASM library. The main components include:

- AST visitors that traverse and transform Groovy class structures
- Bytecode generators that emit JVM instructions
- Verifiers that ensure code correctness and compliance with Java/Groovy semantics
- Support for inner classes, enums, annotations, and other Groovy language features

The primary entry point for bytecode generation is `AsmClassGenerator`, which coordinates the entire class generation process. Various visitor classes handle specific aspects such as annotation processing, inner class resolution, variable scoping, and verification.

Since:
  1.0

- Related Packages
  Package
  Description
  org.codehaus.groovy
  Groovy Language for the JVM
  org.codehaus.groovy.classgen.asm
  ASM-based helpers that support Groovy bytecode generation in the core class generator.
- Class
  Description
  AnnotationVisitor
  An Annotation visitor responsible for: reading annotation metadata (@Retention, @Target, attribute types) verify that an `AnnotationNode` conforms to annotation meta enhancing an `AnnotationNode` AST to reflect real annotation meta
  AsmClassGenerator
  Generates Java class versions of Groovy classes using ASM.
  BytecodeExpression
  Represents some custom bytecode generation by the compiler.
  BytecodeInstruction
  Helper class used by the class generator.
  BytecodeSequence
  This class represents a sequence of `BytecodeInstruction`s or `ASTNode`s.
  ClassCompletionVerifier
  Checks that a class satisfies various conditions including: Incorrect class or method access modifiers No abstract methods appear in a non-abstract class Existence and correct visibility for inherited members Invalid attempts to override final members
  ClassGenerator
  Abstract base class for generator of Java class versions of Groovy AST classes
  ClassGeneratorException
  An exception thrown by the class generator
  DummyClassGenerator
  To generate a class that has all the fields and methods, except that fields are not initialized and methods are empty.
  EnumCompletionVisitor
  Enums have a parent constructor with two arguments from java.lang.Enum.
  EnumVisitor
  Transforms enum classes by adding required methods and fields according to Java enum semantics.
  ExtendedVerifier
  A specialized Groovy AST visitor meant to perform additional verifications upon the current AST.
  FinalVariableAnalyzer
  Analyzes variable assignments to determine if variables are effectively final, which is required for use in closures and lambda expressions.
  FinalVariableAnalyzer.VariableNotFinalCallback
  Callback interface notified when effectively final analysis detects a problem.
  GeneratorContext
  A context shared across generations of a class and its inner classes.
  InnerClassCompletionVisitor
  Completes the transformation of inner classes by adding synthetic fields and constructor parameters needed to maintain references to outer class instances.
  InnerClassVisitor
  Processes inner classes during compilation, handling the creation of synthetic fields and parameters needed for inner class instances to reference their enclosing instances.
  InnerClassVisitorHelper
  Abstract base class providing helper methods for inner class visitors.
  ReturnAdder
  Utility class to add return statements.
  ReturnAdder.ReturnStatementListener
  Listener notified when a synthetic return statement is created.
  VariableScopeVisitor
  Initializes the variable scopes for an AST.
  Verifier
  Verifies the AST node and adds any default AST code before bytecode generation occurs.
  Verifier.DefaultArgsAction
  Strategy invoked for each synthetic method or constructor generated for default arguments.
  VerifierCodeVisitor
  Performs various checks on code inside methods and constructors including checking for valid field, variables names etc.