diff --git a/java-api/src/java9/java/xyz/wagyourtail/jvmdg/j9/stub/java_base/J_L_ProcessHandle.java b/java-api/src/java9/java/xyz/wagyourtail/jvmdg/j9/stub/java_base/J_L_ProcessHandle.java index bc702d36..86990527 100644 --- a/java-api/src/java9/java/xyz/wagyourtail/jvmdg/j9/stub/java_base/J_L_ProcessHandle.java +++ b/java-api/src/java9/java/xyz/wagyourtail/jvmdg/j9/stub/java_base/J_L_ProcessHandle.java @@ -28,10 +28,10 @@ public interface J_L_ProcessHandle extends Comparable { RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); static Optional of(long pid) { - if (pid == current().pid()) { - return Optional.of(current()); + if (UnixProcessHandle.isUnix()) { + return Optional.of(new UnixProcessHandle(pid)); } - throw new UnsupportedOperationException("Getting arbitrary PID process handles is not supported"); + throw MissingStubError.create(); } static J_L_ProcessHandle current() { @@ -49,7 +49,10 @@ public CompletableFuture onExit() { } static Stream allProcesses() { - return Stream.of(current()); + if (UnixProcessHandle.isUnix()) { + return of(0).get().descendants(); + } + throw MissingStubError.create(); } long pid();