Class SandboxCpsTransformer

java.lang.Object
org.codehaus.groovy.control.CompilationUnit.PrimaryClassNodeOperation
org.codehaus.groovy.control.customizers.CompilationCustomizer
com.cloudbees.groovy.cps.CpsTransformer
com.cloudbees.groovy.cps.SandboxCpsTransformer
All Implemented Interfaces:
org.codehaus.groovy.ast.GroovyCodeVisitor

public class SandboxCpsTransformer extends CpsTransformer
CpsTransformer + SandboxTransformer
Author:
Kohsuke Kawaguchi
  • Constructor Details

    • SandboxCpsTransformer

      public SandboxCpsTransformer()
  • Method Details

    • call

      public void call(org.codehaus.groovy.control.SourceUnit source, org.codehaus.groovy.classgen.GeneratorContext context, org.codehaus.groovy.ast.ClassNode classNode)
      Overrides:
      call in class CpsTransformer
    • processConstructors

      protected void processConstructors(org.codehaus.groovy.ast.ClassNode classNode)
      Description copied from class: CpsTransformer
      Constructors can't be transformed - if we throw a CpsCallableInvocation from inside a constructor, there's no way to get back to the continuation. The object does not get created and so we're unable to proceed with it. The same thing applies for object initializers.
      Overrides:
      processConstructors in class CpsTransformer
    • visitNontransformedMethod

      protected void visitNontransformedMethod(org.codehaus.groovy.ast.MethodNode m)
      If the method is not CPS transformed, we need to sandbox-transform that method to intercept calls that happen in these methods. This includes all constructor bodies.
      Overrides:
      visitNontransformedMethod in class CpsTransformer
      See Also:
      • SandboxTransformer.call(org.codehaus.groovy.control.SourceUnit, org.codehaus.groovy.classgen.GeneratorContext, org.codehaus.groovy.ast.ClassNode)
    • visitNontransformedField

      protected void visitNontransformedField(org.codehaus.groovy.ast.FieldNode f)
      Field initializers are never transformed, but we still need to run the sandbox transformer on them.
      Overrides:
      visitNontransformedField in class CpsTransformer
      See Also:
      • SandboxTransformer.call(org.codehaus.groovy.control.SourceUnit, org.codehaus.groovy.classgen.GeneratorContext, org.codehaus.groovy.ast.ClassNode)
    • visitNontransformedStatement

      protected void visitNontransformedStatement(org.codehaus.groovy.ast.stmt.Statement s)
      Miscellaneous statements like object initializers are never transformed, but we still need to run the sandbox transformer on them.
      Overrides:
      visitNontransformedStatement in class CpsTransformer
      See Also:
      • SandboxTransformer.call(org.codehaus.groovy.control.SourceUnit, org.codehaus.groovy.classgen.GeneratorContext, org.codehaus.groovy.ast.ClassNode)
    • visitMethod

      public void visitMethod(org.codehaus.groovy.ast.MethodNode m)
      Overriding to allow for rejecting finalize methods when sandboxed.
      Overrides:
      visitMethod in class CpsTransformer
    • getTrustTag

      protected Class getTrustTag()
      Description copied from class: CpsTransformer
      Trusted or Untrusted tag that gets added to call site.
      Overrides:
      getTrustTag in class CpsTransformer
      See Also:
      • "doc/sandbox.md"