Class SandboxMethodPointer

java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.lang.Closure<Object>
com.axelor.script.SandboxClosure<Object>
com.axelor.script.SandboxMethodPointer
All Implemented Interfaces:
SandboxCode, groovy.lang.GroovyCallable<Object>, groovy.lang.GroovyObject, Serializable, Cloneable, Runnable, Callable<Object>

public final class SandboxMethodPointer extends SandboxClosure<Object>
A method pointer created by a script (obj.&name, obj::name, Type::new).

Its owner is validated when it is created (see GroovySandbox.methodPointer(Object)), but the receiver of its calls is not always the owner: when the owner is a class, Groovy calls an instance method of that class on the first argument (String::toUpperCase applied to 'a'). That argument is then validated as the receiver, as a direct call on it would be.

The calls are delegated to the MethodClosure created by Groovy, so they are resolved exactly as Groovy does. It is kept in a SandboxMethodPointer.Target, a class the policy does not allow: Groovy reads private fields, and the method closure itself must not be called without this check (e.g. by passing it to each). As a SandboxClosure, the pointer is sandboxed code, also when trusted code calls it later.

See Also:
  • Method Details

    • getMethod

      public String getMethod()
      The name of the method, or new for a constructor.
    • getProperty

      public Object getProperty(String property)
      Specified by:
      getProperty in interface groovy.lang.GroovyObject
      Overrides:
      getProperty in class SandboxClosure<Object>
    • doCall

      public Object doCall(Object... arguments)