code: public static int getfd(FileDescriptor descriptor)
    {
      try {
        return field.getInt(descriptor);
      }
      catch (IllegalArgumentException | IllegalAccessException e) {
        log.warn("Unable to read fd field from java.io.FileDescriptor");
      }
  
      return -1;
    }
docs: Get system file descriptor (int) from FileDescriptor object.
  @param descriptor - FileDescriptor object to get fd from
  @return file descriptor, -1 or error