Class ScriptAwareAnnotation

java.lang.Object
org.elasticsearch.painless.spi.annotation.ScriptAwareAnnotation

public class ScriptAwareAnnotation extends Object
Marks a whitelisted augmentation method as script-aware: in script contexts that activate it, the lookup builder resolves the call to an augmentation overload that takes a leading PainlessScript parameter, and the compiler emits aload 0 (the script receiver) ahead of the user-supplied arguments at every call site. The augmentation body can then use the script instance directly — for example Iterable.each uses it to poll the script's cancellation runnable from inside its own iteration loop so long loops in non-Painless code honour task cancellation.

In contexts that do not activate it, the annotation is silently dropped during lookup resolution: the call resolves to whatever the whitelist line would have resolved to without the annotation (an existing augmentation overload, or the direct JDK method). Non-activated contexts pay zero overhead.