@GroovyASTTransformation(phase = CompilePhase.CONVERSION)
public class RecordBaseASTStubber
extends AbstractASTTransformation
Joint-compilation stubber for RecordBase. For emulated records
(target < JDK16 or explicit mode = EMULATE) it produces
the same Java-callable surface that the runtime transform produces at
SEMANTIC_ANALYSIS:
Verifier
sub-pass emits componentName() accessors instead of
getComponentName() and skips setter synthesis on the
(now-final) properties.getAt(int), toList(), toMap(),
size(), plus the opt-in copyWith(Map) and
components() when enabled via @RecordOptions.The "should we add this?" predicates are shared with the full
transform via package-private statics on
RecordTypeASTTransformation, so the stub never exposes a method
the runtime won't add (matching the same subset invariant as
@Delegate's shared filter helpers).
The canonical constructor on the stub comes transitively from the
existing @TupleConstructor stubber, which @RecordType's
@AnnotationCollector pulls in.
Native records. When the class would compile as a native JVM
record (target >= JDK16 and mode != EMULATE), the stub
generator already renders record Foo(...) syntax via the
back-channel introduced by GROOVY-11974, and javac synthesises
the canonical constructor and component accessors itself. This stubber
detects that case via
RecordTypeASTTransformation.wouldBeNativeRecord and bails out;
applying property modifier flips or stubbing convenience methods on a
native-record AST would interfere with subsequent record-component
processing.
| Fields inherited from class | Fields |
|---|---|
class AbstractASTTransformation |
RETENTION_CLASSNODE, sourceUnit |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
visit(ASTNode[] nodes, SourceUnit source) |