Class SandboxViolation

java.lang.Object
org.codehaus.commons.compiler.sandbox.SandboxViolation
All Implemented Interfaces:
Serializable

public final class SandboxViolation extends Object implements Serializable
A reason why a BytecodeVerifier rejected a class.

If the class file contains line numbers (i.e. it was compiled with debugging information), then a violation that concerns the use of a field, method or constructor carries the source line where it is used, see getLocation().

See Also:
  • Method Details

    • getClassName

      public String getClassName()
      Returns:
      The name of the rejected class, e.g. "pkg.Foo$1"
    • getMessage

      public String getMessage()
      Returns:
      A human-readable description of the violation, e.g. "Access to java.lang.System.getProperty(java.lang.String) is not permitted by the sandbox policy"
    • getFileName

      @Nullable public String getFileName()
      Returns:
      The name of the source file of the rejected class (as recorded in its class file), or null iff unknown
    • getLineNumber

      public int getLineNumber()
      Returns:
      The source line where the violating field, method or constructor is used, or -1 iff unknown (e.g. because the class file contains no line numbers, or because the violation concerns the class as a whole, like a forbidden superclass)
    • getLocation

      @Nullable public Location getLocation()
      Returns:
      The location of the violation in the source code, or null iff the line number is unknown; the column number of the location is 0, which means "the entire line"
    • withLocation

      public SandboxViolation withLocation(@Nullable String fileName, int lineNumber)
      Returns a copy of this violation with the given file name and line number. Compilers use this to map the locations in the generated code to the locations in the document that they compiled.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      E.g. "File 'script.txt', Line 3: Access to ... is not permitted by the sandbox policy", or, iff the location is unknown, "pkg.Foo: Extending ... is not permitted by the sandbox policy"