@GroovyASTTransformation(phase = CompilePhase.CONVERSION)
public class AutoCloneASTStubber
extends AbstractASTTransformation
Joint-compilation stubber for AutoClone. Adds the
Cloneable interface to the class header and emits a placeholder
public Foo clone() so Java consumers can call the
AutoClone-generated covariant clone() against the
joint-compilation stub.
Without this, Java sees only Object.clone() (which is
protected), so foo.clone() from Java fails to compile
even though the runtime exposes a public covariant override.
The placeholder's throws clause is computed by
AutoCloneASTTransformation.cloneExceptionsFor so it
is a legal Java override of the superclass clone() (e.g. a
subclass of HashMap must not declare
CloneNotSupportedException since HashMap.clone() doesn't).
The full AutoCloneASTTransformation at CANONICALIZATION
removes the stubber-tagged placeholder before installing whichever
clone() body the chosen style produces (CLONE,
COPY_CONSTRUCTOR, SERIALIZATION, or SIMPLE).
| Fields inherited from class | Fields |
|---|---|
class AbstractASTTransformation |
RETENTION_CLASSNODE, sourceUnit |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
visit(ASTNode[] nodes, SourceUnit source) |