Package: groovy.transform

## [Java] Annotation Type Virtual

- groovy.transform.Virtual

-     @Documented
      @Retention(RetentionPolicy.RUNTIME)
      @Target(ElementType.METHOD)
      public @interface Virtual

  Marks a public trait `static` method as virtual: trait-body calls to this method dispatch through the implementing class at runtime, so a same-signature static method declared on the implementing class overrides the trait's default.

  This is the opt-in counterpart to the default declarer-bound dispatch for trait static methods (where trait-body calls always invoke the trait's own copy regardless of any same-named static on the implementer). The opt-in restores the per-implementer override pattern used by Grails' `Validateable.defaultNullable()` and similar framework hooks.

  The marker is per-callee, not per-caller: it changes how trait code invokes the annotated method, regardless of which method inside the trait does the calling.

  Valid only on public, non-abstract `static` trait methods. Applying it to an instance method, a private method, an abstract method, or anything outside a trait is a compile-time error. Unlike plain trait statics, an `@Virtual` method is not promoted to a JVM-native interface static on the trait interface — interface statics are declarer-bound by JVM rule and incompatible with virtual dispatch — so external callers reach the method through the implementer rather than via `Trait.m()`.

  Since:
    6.0.0

- - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`