public class InnerClassNode
extends ClassNode
Represents a nested (inner) class definition within an outer class. Inner classes maintain a reference to their enclosing ClassNode and support Groovy-specific features such as variable scoping and anonymous class detection. Automatically marks inner classes as static when defined in interfaces per JLS specifications.
| Fields inherited from class | Fields |
|---|---|
class ClassNode |
EMPTY_ARRAY, SUPER, THIS, clazz, isPrimaryNode, lazyInitLock |
| Constructor and description |
|---|
InnerClassNode(ClassNode outerClass, String name, int modifiers, ClassNode superClass)Creates an inner class with the specified outer class, name, modifiers, and superclass. |
InnerClassNode(ClassNode outerClass, String name, int modifiers, ClassNode superClass, ClassNode[] interfaces, MixinNode[] mixins)Creates an inner class with the specified outer class, name, modifiers, superclass, interfaces, and mixins. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public ClassNode |
getOuterClass()Returns the class that encloses this inner class, or null if this is a top-level class. |
|
public FieldNode |
getOuterField(String name)Retrieves a field from the enclosing class by name, enabling access to outer class fields from within the inner class scope. |
|
public ClassNode |
getOuterMostClass()Returns the outermost class in the nesting hierarchy by recursively traversing outer class references until reaching a class that has no outer class. |
|
public VariableScope |
getVariableScope()Returns the variable scope associated with this inner class, tracking declarations and references for closure and method boundary analysis. |
|
public boolean |
isAnonymous()Returns whether this inner class represents an anonymous class (created with inline expressions). |
|
public boolean |
isSealed()Checks if this inner class is sealed per JLS 15.9.5, returning false for anonymous classes since they cannot be further subclassed. |
|
public void |
setAnonymous(boolean anonymous)Marks this inner class as anonymous if not already set. |
|
public void |
setVariableScope(VariableScope scope)Sets the variable scope that manages variables declared and referenced within this inner class. |
Creates an inner class with the specified outer class, name, modifiers, and superclass.
outerClass - the enclosing class, or null for top-level classesname - the fully qualified name of the inner classmodifiers - the org.objectweb.asm.Opcodes modifiers for this classsuperClass - the superclass of this inner class, or ClassNode.EMPTY_ARRAY for ObjectCreates an inner class with the specified outer class, name, modifiers, superclass, interfaces, and mixins. If the outer class is an interface, the inner class is automatically marked as static.
outerClass - the enclosing class, or null for top-level classesname - the fully qualified name of the inner classmodifiers - the org.objectweb.asm.Opcodes modifiers for this classsuperClass - the superclass of this inner classinterfaces - the interfaces implemented by this inner classmixins - the mixins applied to this inner classReturns the class that encloses this inner class, or null if this is a top-level class.
Retrieves a field from the enclosing class by name, enabling access to outer class fields from within the inner class scope.
name - the field name to retrieve from the outer classReturns the outermost class in the nesting hierarchy by recursively traversing outer class references until reaching a class that has no outer class.
Returns the variable scope associated with this inner class, tracking declarations and references for closure and method boundary analysis.
Returns whether this inner class represents an anonymous class (created with inline expressions).
Checks if this inner class is sealed per JLS 15.9.5, returning false for anonymous classes since they cannot be further subclassed.
Marks this inner class as anonymous if not already set. Anonymous classes have restricted modifiers: static and abstract modifiers are removed, and final is removed for enums per JLS 15.9.5. Once set to anonymous, this state cannot be reverted.
anonymous - true to mark this inner class as anonymousSets the variable scope that manages variables declared and referenced within this inner class.
scope - the VariableScope to associate with this inner classCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.