java/kudu-client/src/test/java/org/apache/kudu/client/TestUtils.java
static int pidOfProcess(Process proc) throws Exception {
    Class<?> procCls = proc.getClass();
    try {
      // Note: In Java 9+ you can call proc.getPid(). We use reflection
      // because we support earlier version of java.
      Field pidField = procCls.getDeclaredField("pid");
      pidField.setAccessible(true);
      return (Integer) pidField.get(proc);
    } catch (ReflectiveOperationException e) {
      throw new IllegalArgumentException("pidOfProcess could not find or access the pid field" +
          "via reflection on the class " + procCls.getName(), e);
    }
  }
/**
   * Gets the pid of a specified process. Relies on reflection and only works on
   * UNIX process, not guaranteed to work on JDKs other than Oracle and OpenJDK.
   * @param proc The specified process.
   * @return The process UNIX pid.
   * @throws IllegalArgumentException If the process is not a UNIXProcess.
   * @throws Exception If there are other getting the pid via reflection.
   */
Gets the pid of a specified process. Relies on reflection and only works on
UNIX process, not guaranteed to work on JDKs other than Oracle and OpenJDK.
@param proc The specified process.
@return The process UNIX pid.
@throws IllegalArgumentException If the process is not a UNIXProcess.
@throws Exception If there are other getting the pid via reflection.
Gets the pid of a specified process . Relies on reflection and only works on UNIX process not guaranteed to work on JDKs other than Oracle and OpenJDK . @param proc The specified process . @return The process UNIX pid . @throws IllegalArgumentException If the process is not a UNIXProcess . @throws Exception If there are other getting the pid via reflection .
static int pidOfProcess(Process proc) throws Exception {
    Class<?> procCls = proc.getClass();
    try {
      Field pidField = procCls.getDeclaredField("pid");
      pidField.setAccessible(true);
      return (Integer) pidField.get(proc);
    } catch (ReflectiveOperationException e) {
      throw new IllegalArgumentException("pidOfProcess could not find or access the pid field" +
          "via reflection on the class " + procCls.getName(), e);
    }
  }
static int pidOfProcess ( Process proc ) throws Exception { Class < ? > procCls = proc . getClass ( ) ; try { Field pidField = procCls . getDeclaredField ( "pid" ) ; pidField . setAccessible ( true ) ; return ( Integer ) pidField . get ( proc ) ; } catch ( ReflectiveOperationException e ) { throw new IllegalArgumentException ( "pidOfProcess could not find or access the pid field" + "via reflection on the class " + procCls . getName ( ) , e ) ; } }
Gets the pid of a specified process.
Gets the pid of a specified process .
// Note: In Java 9+ you can call proc.getPid(). We use reflection // because we support earlier version of java.