public class DecompiledClassNode
extends ClassNode
Represents a ClassNode for classes loaded from compiled bytecode files decompiled using ASM. This class bridges the gap between raw bytecode metadata and Groovy's AST representation, providing lazy initialization of all class members to enable efficient runtime class loading and introspection without requiring source code.
DecompiledClassNode is a deferred factory for AST nodes: it collects bytecode metadata from a ClassStub and reconstructs full AST nodes (methods, fields, constructors) on demand via lazy proxy classes (LazyFieldNode, LazyMethodNode, LazyConstructorNode). This enables Groovy to compile and introspect compiled classes without full bytecode decompilation upfront.
true.
Unlike source-based classes that transition from unresolved to resolved, decompiled classes
are inherently resolved because their metadata is extracted from compiled bytecode.isPrimaryNode = false. This indicates the class is
derived from compiled bytecode rather than primary source compilation.DecompiledClassNode uses a two-phase lazy initialization pattern with double-checked locking:
DecompiledClassNode is thread-safe for lazy initialization. Both lazyInitSupers()
and lazyInitMembers() use double-checked locking with volatile flags to ensure single
initialization across multiple threads. The implementation protects initialization with
lazyInitLock (inherited from ClassNode) to serialize critical sections.
The ASM decompiler and reference resolver are cached at the DecompiledClassNode level but not across multiple class loads. When the same bytecode is parsed by different AsmDecompiler instances, separate DecompiledClassNode instances are created. This ensures consistency within a compilation context.
For nested classes, the INNERCLASS bytecode attribute (JVMS 4.7.6) provides authoritative
access modifiers that correctly reflect nested visibility. getModifiers(ClassStub)
prefers innerClassModifiers over the top-level accessModifiers when available.
Groovy embeds compilation timestamps in synthetic static field names for change detection. getCompilationTimeStamp() decodes this metadata using Verifier.getTimestampFromFieldName.
| Fields inherited from class | Fields |
|---|---|
class ClassNode |
EMPTY_ARRAY, SUPER, THIS, clazz, isPrimaryNode, lazyInitLock |
| Constructor and description |
|---|
DecompiledClassNode(ClassStub classData, AsmReferenceResolver resolver)Creates a DecompiledClassNode from a class stub extracted from bytecode. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public List<AnnotationNode> |
getAnnotations()Returns all annotations attached to this class. |
|
public List<AnnotationNode> |
getAnnotations(ClassNode type)Returns annotations of a specific type attached to this class. |
|
public long |
getCompilationTimeStamp()Extracts the compilation timestamp from static field metadata if present. |
|
public List<ConstructorNode> |
getDeclaredConstructors()Returns all constructors declared by this class. |
|
public FieldNode |
getDeclaredField(String name)Returns a field declared by this class with the given name. |
|
public List<MethodNode> |
getDeclaredMethods(String name)Returns all methods declared by this class with the given name. |
|
public List<FieldNode> |
getFields()Returns all fields declared by this class (excluding inherited fields). |
|
public GenericsType[] |
getGenericsTypes()Returns the generic type parameters of this class. |
|
public ClassNode[] |
getInterfaces()Returns the interfaces implemented by this class. |
|
public List<MethodNode> |
getMethods()Returns all methods and constructors declared by this class (excluding inherited methods). |
|
public List<RecordComponentNode> |
getRecordComponents()Returns the record components of this record class (Java 16+). |
|
public Class |
getTypeClass()Resolves the runtime JVM Class object for this decompiled class node. |
|
public ClassNode[] |
getUnresolvedInterfaces(boolean useRedirect)Returns the unresolved (not yet redirected) interfaces implemented by this class. |
|
public ClassNode |
getUnresolvedSuperClass(boolean useRedirect)Returns the unresolved (not yet redirected) superclass of this class. |
|
public boolean |
isParameterized()Determines whether this class has generic type parameters by inspecting the bytecode signature. |
|
public boolean |
isResolved()Reports that this class node is fully resolved from bytecode. |
|
public boolean |
isSealed()Determines if this class is sealed, checking both Java sealed class annotations and Groovy @Sealed transform annotations. |
|
public boolean |
isUsingGenerics()Indicates whether this class is using generic types. |
|
public void |
setGenericsPlaceHolder(boolean b)Prevents marking decompiled class nodes as generic placeholders. |
|
public String |
setName(String name)Prevents renaming of decompiled class nodes, as they represent immutable bytecode definitions. |
|
public void |
setRedirect(ClassNode cn)Prevents redirection of decompiled class nodes to alternate implementations. |
|
public void |
setUsingGenerics(boolean b)Prevents modification of generic type usage for decompiled class nodes. |
Creates a DecompiledClassNode from a class stub extracted from bytecode.
classData - the ClassStub containing bytecode-derived metadataresolver - the AsmReferenceResolver used to resolve class referencesReturns all annotations attached to this class. Triggers lazy initialization of superclass and interface metadata.
Returns annotations of a specific type attached to this class. Triggers lazy initialization of superclass and interface metadata.
type - the annotation type to filter byExtracts the compilation timestamp from static field metadata if present. Groovy embeds compilation timestamps in synthetic static field names using a special encoding.
Long.MAX_VALUE if not availableReturns all constructors declared by this class. Triggers lazy initialization of class members.
Returns a field declared by this class with the given name. Triggers lazy initialization of class members.
name - the field namenull if no such field existsReturns all methods declared by this class with the given name. Triggers lazy initialization of class members.
name - the method nameReturns all fields declared by this class (excluding inherited fields). Triggers lazy initialization of class members.
Returns the generic type parameters of this class. Triggers lazy initialization of generic type information from the class signature.
Returns the interfaces implemented by this class. Triggers lazy initialization of interface metadata from the bytecode.
Returns all methods and constructors declared by this class (excluding inherited methods). Triggers lazy initialization of class members.
Returns the record components of this record class (Java 16+). Triggers lazy initialization of superclass and interface metadata.
Resolves the runtime JVM Class object for this decompiled class node.
Returns the unresolved (not yet redirected) interfaces implemented by this class. Triggers lazy initialization of interface metadata.
useRedirect - whether to follow class redirects (typically false for decompiled classes)Returns the unresolved (not yet redirected) superclass of this class. Triggers lazy initialization of superclass metadata.
useRedirect - whether to follow class redirects (typically false for decompiled classes) Determines whether this class has generic type parameters by inspecting the bytecode signature.
A parameterized class signature begins with '<' to indicate type variable declarations.
true if the class signature contains generic type parametersReports that this class node is fully resolved from bytecode. Decompiled classes are always resolved, unlike source-based classes which may be unresolved during compilation.
true for decompiled classes Determines if this class is sealed, checking both Java sealed class annotations
and Groovy @Sealed transform annotations.
true if the class is declared as sealed with either Java or Groovy mechanismsIndicates whether this class is using generic types. Triggers lazy initialization of generic type information.
true if the class uses generic type parametersPrevents marking decompiled class nodes as generic placeholders.
b - ignoredPrevents renaming of decompiled class nodes, as they represent immutable bytecode definitions.
name - ignoredPrevents redirection of decompiled class nodes to alternate implementations.
cn - ignoredPrevents modification of generic type usage for decompiled class nodes.
b - ignoredCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.