Class Java8Process

All Implemented Interfaces:
SystemProcess

public class Java8Process extends JavaProcess
Wrapper for Process since Java 8.

Java 8 added following methods:

  • isAlive()
  • destroyForcibly()
  • waitFor(long, TimeUnit)
  • Constructor Details

    • Java8Process

      public Java8Process(Process process)
  • Method Details

    • isSupported

      public static boolean isSupported()
    • canDestroy

      protected boolean canDestroy(boolean forceful)
      Description copied from class: JavaProcess
      Check if destroying the process is supported based on the OS and JVM version (regardless the process is running or not).
      Overrides:
      canDestroy in class JavaProcess
      Parameters:
      forceful - true if the process must be destroyed forcefully (like kill -KILL), false if it must be destroyed gracefully (like kill -TERM).
      Returns:
      true if JavaProcess.invokeDestroy(boolean) is supported with the given forceful flag on the given system.
    • invokeDestroy

      protected void invokeDestroy(boolean forceful)
      Overrides:
      invokeDestroy in class JavaProcess
    • invokeDestroyForcibly

      public Process invokeDestroyForcibly()
    • isAlive

      public boolean isAlive()
      Description copied from interface: SystemProcess
      Tests whether this process is alive.

      This operation may take some time to finish.

      Specified by:
      isAlive in interface SystemProcess
      Overrides:
      isAlive in class JavaProcess
      Returns:
      true if this process is alive, false if it is finished or not found.
    • waitFor

      public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException
      Description copied from class: AbstractProcess
      Causes the current thread to wait, if necessary, until the process handled by this killer has terminated, or the specified timeout is reached.

      If the process has already terminated then this method returns immediately with the value true. If the process has not terminated and the timeout value is less than, or equal to, zero, then this method returns immediately with the value false.

      Specified by:
      waitFor in interface SystemProcess
      Overrides:
      waitFor in class AbstractProcess
      Parameters:
      timeout - the maximum time to wait
      unit - the time unit of the timeout argument
      Returns:
      true if the process has exited and false if the timeout is reached before the process has exited.
      Throws:
      InterruptedException - if interrupted.