Class SandboxLimits.Builder

java.lang.Object
org.codehaus.commons.compiler.sandbox.SandboxLimits.Builder
Enclosing class:
SandboxLimits

public static final class SandboxLimits.Builder extends Object
Creates SandboxLimits.
  • Method Details

    • timeout

      public SandboxLimits.Builder timeout(long duration, TimeUnit unit)
      Limits the wall-clock time of an execution.
      Parameters:
      duration - Must be positive
    • maxTicks

      public SandboxLimits.Builder maxTicks(long maxTicks)
      Limits the number of "ticks" of an execution. Code that JANINO compiles with a SandboxPolicy ticks once per loop iteration and once per method or constructor invocation. This limit is deterministic, i.e. independent of the speed of the machine.
      Parameters:
      maxTicks - Must be positive
    • maxAllocatedBytes

      public SandboxLimits.Builder maxAllocatedBytes(long maxAllocatedBytes)
      Limits the number of bytes that the executing thread allocates on the heap. The allocated bytes are measured with com.sun.management.ThreadMXBean.getThreadAllocatedBytes(long); on JVMs that do not support it, this limit is not enforced (see SandboxLimits.isMemoryLimitSupported()).
      Parameters:
      maxAllocatedBytes - Must be positive
    • build

      public SandboxLimits build()