<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def execute_runner(runner, workunit_factory=None, workunit_name=None, workunit_labels=None, workunit_log_config=None, stdin=None):
 """Executes the given java runner. If `workunit_factory` is supplied, does so in the context of a workunit. :param runner: the java runner to run :param workunit_factory: an optional callable that can produce a workunit context :param string workunit_name: an optional name for the work unit; defaults to the main :param list workunit_labels: an optional sequence of labels for the work unit :param WorkUnit.LogConfig workunit_log_config: an optional tuple of task options affecting reporting :param file stdin: The stdin handle to use: by default None, meaning that stdin will not be propagated into the process. Returns the exit code of the java runner. Raises `pants.java.Executor.Error` if there was a problem launching java itself. """

  if not isinstance(runner, Executor.Runner):
    raise ValueError('The runner argument must be a java Executor.Runner instance, '
                     'given {} of type {}'.format(runner, type(runner)))

  if workunit_factory is None:
    return runner.run(stdin=stdin)
  else:
    workunit_labels = [
        WorkUnitLabel.TOOL,
        WorkUnitLabel.NAILGUN if isinstance(runner.executor, NailgunExecutor) else WorkUnitLabel.JVM
    ] + (workunit_labels or [])

    with workunit_factory(name=workunit_name, labels=workunit_labels,
                          cmd=runner.cmd, log_config=workunit_log_config) as workunit:
      ret = runner.run(stdout=workunit.output('stdout'),
                       stderr=workunit.output('stderr'),
                       stdin=stdin)
      workunit.set_outcome(WorkUnit.FAILURE if ret else WorkUnit.SUCCESS)
      return ret