anchor.diff:  }
   ----
   
  +.Kotlin
  +[source,kotlin,role=secondary]
  +----
  +import com.google.inject.*
  +import picocli.CommandLine
  +import picocli.CommandLine.IFactory
  +
  +class GuiceFactory : IFactory {
  +    private val injector = Guice.createInjector(DemoModule())
  +
  +    @Throws(Exception::class)
  +    override fun <K> create(aClass: Class<K>): K {
  +        return try {
  +            injector.getInstance(aClass)
  +        } catch (ex: ConfigurationException) { // no implementation found in Guice configuration
  +            CommandLine.defaultFactory().create(aClass) // fallback if missing
  +        }
  +    }
  +
  +    class DemoModule : AbstractModule() {
  +        override fun configure() {
  +            bind(object : TypeLiteral<kotlin.collections.List<*>>() {})
  +                .toInstance(kotlin.collections.ArrayList<Any>())
  +        }
  +    }
  +}
  +----
  +
   Use the custom factory when creating a `CommandLine` instance, or when invoking the `run` or `call` convenience methods:
   
  -[source,java]
  +.Java
  +[source,java,role="primary"]
   ----
   import javax.inject.*;
  -import picocli.*;
  +import picocli.CommandLine;
   import picocli.CommandLine.*;
   
   @Command(name = "di-demo")
  
positive.code:     public void run() {
          assert list instanceof java.util.LinkedList;
      }
  }
  ----
  
  
negative.code: 
  The below example shows how to create a <<Custom Factory,custom `IFactory`>> implementation with a Guice `Injector`:
  
  .Java
  [source,java,role="primary"]
  ----
  import com.google.inject.*;
  import picocli.CommandLine;
  