Class Privileged

java.lang.Object
org.codehaus.commons.compiler.util.Privileged

public final class Privileged extends Object
Runs actions with the privileges of the calling code, regardless of the permissions of the code further up the call stack.

On JVMs that provide the java.security.AccessController API, this is equivalent to AccessController.doPrivileged(PrivilegedAction). That matters on JVMs where a security manager can be installed (Java 8 through 23). Should a future JVM no longer provide that API, the action is simply executed.

  • Method Details

    • run

      public static <T> T run(Supplier<T> action)
      Runs the given action with the privileges of the calling code.
      Returns:
      The value returned by the action