Skip to content

tools: Injecting standard streams #26

@tombentley

Description

@tombentley

The tools framework currently doesn't do anything special for the standard streams (stdout, stderr & stdin): If a tool wants to print to standard output or error it just uses System.out.println()/System.err.println(). I'm wondering if we should change this. If the top level tool was responsible for injecting the PrintStreams (and InputStream in the case of standard input) it would:

  • simplify testing (in particular test isolation when testing concurrently, which prevents the TopLevelToolTest running in the compiler tests),
  • work better in those cases where the tool is being embedded in another program (rather than the more usual case of command line execution).

It would mean that tools would need to use the injected streams instead of reaching immediately for System.*.

The other way of looking at this is that tools "shouldn't" be reaching for raw streams at all, but should be using logging. In which case this becomes a question about whether it is the top level tool's job to configure logging, or the individual tools', or some combination.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions