private void setDefaultInputStream(GantBinding binding) {

    // Gant does not initialise the default input stream for
    // the Ant project, so we manually do it here.
    AntBuilder antBuilder = (AntBuilder) binding.getVariable("ant");
    Project p = antBuilder.getAntProject();

    try {
      System.setIn(originalIn);
      p.setInputHandler(new CommandLineInputHandler());
      p.setDefaultInputStream(originalIn);
    } catch (NoSuchMethodError nsme) {
      // will only happen due to a bug in JRockit
      // note - the only approach that works is to loop through the public methods
      for (Method m : p.getClass().getMethods()) {
        if ("setDefaultInputStream".equals(m.getName())
            && m.getParameterTypes().length == 1
            && InputStream.class.equals(m.getParameterTypes()[0])) {
          try {
            m.invoke(p, originalIn);
            break;
          } catch (Exception e) {
            // shouldn't happen, but let it bubble up to the catch(Throwable)
            throw new RuntimeException(e);
          }
        }
      }
    }
  }