int (@NotNull Process process) { try { if (JavaVersion.current().feature >= 9 && "java.lang.ProcessImpl".equals(process.getClass().getName())) { return ((Long)Process.class.getMethod("pid").invoke(process)).intValue(); } else { return Objects.requireNonNull(ReflectionUtil.getField(process.getClass(), process, int.class, "pid")); } } catch (Throwable t) { throw new IllegalStateException("Failed to get PID from an instance of " + process.getClass() + ", OS: " + SystemInfo.OS_NAME, t); } }