JEP 102: Process API Updates
|Status||Proposed to Target|
|Component||core-libs / java.lang|
|Discussion||core dash libs dash dev at openjdk dot java dot net|
|Endorsed by||Brian Goetz|
|Blocks||8044122: MBean access to the PID|
|8044840: [TESTBUG] get rid of JMX in com.oracle.java.testlibrary.ProcessTools.getProcessId() for getting current process id|
|Depends||8049867: JEP-JDK-8046092: Dev: Scoping and Schedule|
|Relates to||8003490: (process) Provide Process.getCurrentPid() to get identifier of current process|
|4333183: (process) Add a way to gently shutdown, as opposed to destroy, a subprocess|
|6439432: (process) Access to system-specific process-related APIs|
|6447323: (process) Native OS process information and control|
|4076796: (process) Provide Process.isAlive(), like Thread.isAlive()|
|4890847: (process) Add Process.ID and Process.waitFor(long timeout)|
Improve the API for controlling and managing operating system processes.
Long-standing shortcoming in the platform, requiring applications to resort to native code. Long requested by developers.
Java SE provides limited support for native operating system processes. It provides a basic API to setup the environment and start a Process. The Process streams can (since Java SE 7) be redirected to files, pipes, or can be inherited. Once started, the API can be used to destroy the process and/or wait for the Process to terminate.
Many enterprise applications and containers involve several Java virtual machines and processes and have long-standing needs which include:
The ability to get the pid (or equivalent) of the current Java virtual machine and the pid of processes created with the existing Process API.
The ability to get/set the process name of the current Java virtual machine and processes created with the Process API (where possible).
The ability to enumerate Java virtual machines and processes on the system. Information on each process may include its pid, name, state, and maybe resource usage.
The ability to deal with process trees, in particular some means to destroy a process tree.
The ability to deal with hundreds of sub-processes, perhaps multiplexing the output or error streams to avoid creating a thread per sub-process.
The classes or methods introduced will require new unit tests that can be developed along with the implementation. More functional tests would be useful too.
Risks and Assumptions
The main risk with this API is differences between operating systems (Windows in particular).
The design of this API needs to take possible deployment on smaller devices with different operating system models. It should also take into account environments where multiple Java virtual machines are running in the same operating system process. These considerations could require result in a more abstract API and/or increase the design effort.
- Compatibility: New JCK test development
- Documentation: Probably updates to the tutorial/guides