Advanced Features

Garbage Collection

A garbage collector is included in distage by default. Given a set of GC root keys, GC will remove all bindings that are neither direct nor transitive dependencies of the supplied roots – these bindings will be thrown out and never instantiated.

GC serves two important purposes:

  • It enables faster tests by omitting unrequired instantiations and initialization of potentially heavy resources,
  • It enables multiple independent applications, aka “Roles” to be hosted within a single .jar file.

To use garbage collector, pass GC roots as an argument to Injector.produce* methods:

import distage._

class A(b: B) {
  println("A!")
}
class B() {
  println("B!")
}
class C() {
  println("C!")
}

val module = new ModuleDef {
  make[A]
  make[B]
  make[C]
}
// module: AnyRef with ModuleDef = Module(make[{type.repl.Session::repl.Session.App0::repl.Session.App0.C}].from(call(<function1>(): repl.Session::repl.Session.App0::repl.Session.App0.C)) ((advanced-features.md:32)), make[{type.repl.Session::repl.Session.App0::repl.Session.App0.A}].from(call(<function1>(repl.Session::repl.Session.App0::repl.Session.App0.B): repl.Session::repl.Session.App0::repl.Session.App0.A)) ((advanced-features.md:30)), make[{type.repl.Session::repl.Session.App0::repl.Session.App0.B}].from(call(<function1>(): repl.Session::repl.Session.App0::repl.Session.App0.B)) ((advanced-features.md:31)))

// declare `A` as a GC root

val gc = GCMode(root = DIKey.get[A])
// gc: GCMode = GCRoots(Set({type.repl.Session::repl.Session.App0::repl.Session.App0.A}))

// create an object graph from description in `module`
// with `A` as a GC root

val objects = Injector().produce(module, gc).unsafeGet()
// B!
// A!
// objects: izumi.fundamentals.platform.functional.package.Identity[Locator] = izumi.distage.LocatorDefaultImpl@5038fbb6

// A and B are in the object graph

objects.find[A]
// res1: Option[A] = Some(repl.Session$App0$A@3463b915)

objects.find[B]
// res2: Option[B] = Some(repl.Session$App0$B@47a99ecc)

// C is missing

objects.find[C]
// res3: Option[C] = None

Class C was removed because neither B nor A depended on it. It’s not present in the Locator and the "C!" message has never been printed. If class B had a C parameter, like class B(c: C); C would have been retained, because A - the GC root, would depend on B, and B would depend on C.

class B(c: C) {
  println("B!")
}

val objects = Injector().produce(module, GCMode(DIKey.get[A])).unsafeGet()
// C!
// B!
// A!
// objects: izumi.fundamentals.platform.functional.package.Identity[Locator] = izumi.distage.LocatorDefaultImpl@2d573f83

objects.find[C]
// res5: Option[C] = Some(repl.Session$App4$C@18ec96f4)

Circular Dependencies Support

distage automatically resolves arbitrary circular dependencies, including self-references:

import distage.{GCMode, ModuleDef, Injector}

class A(val b: B)
class B(val a: A)  
class C(val c: C)

val objects = Injector().produce(new ModuleDef {
  make[A]
  make[B]
  make[C]
}, GCMode.NoGC).unsafeGet()
// objects: izumi.fundamentals.platform.functional.package.Identity[izumi.distage.model.Locator] = izumi.distage.LocatorDefaultImpl@edf07db

objects.get[A] eq objects.get[B].a
// res7: Boolean = true
objects.get[B] eq objects.get[A].b
// res8: Boolean = true
objects.get[C] eq objects.get[C].c
// res9: Boolean = true

Automatic Resolution with generated proxies

The above strategy depends on distage-core-proxy-cglib module which is a default dependency of distage-core.

If you want to disable it, use NoProxies bootstrap configuration:

Injector.NoProxies()
// res10: Injector = izumi.distage.InjectorDefaultImpl@343e9e58

Proxies are not supported on Scala.js.

Manual Resolution with by-name parameters

Most cycles can be resolved without proxies, using By-Name parameters:

import distage.{GCMode, ModuleDef, Injector}

class A(b0: => B) {
  def b: B = b0
}

class B(a0: => A) {
  def a: A = a0
}

class C(self: => C) {
  def c: C = self
}

val module = new ModuleDef {
  make[A]
  make[B]
  make[C]
}
// module: AnyRef with ModuleDef = Module(make[{type.repl.Session::repl.Session.App11::repl.Session.App11.C}].from(call(<function1>(repl.Session::repl.Session.App11::repl.Session.App11.C): repl.Session::repl.Session.App11::repl.Session.App11.C)) ((advanced-features.md:158)), make[{type.repl.Session::repl.Session.App11::repl.Session.App11.A}].from(call(<function1>(repl.Session::repl.Session.App11::repl.Session.App11.B): repl.Session::repl.Session.App11::repl.Session.App11.A)) ((advanced-features.md:156)), make[{type.repl.Session::repl.Session.App11::repl.Session.App11.B}].from(call(<function1>(repl.Session::repl.Session.App11::repl.Session.App11.A): repl.Session::repl.Session.App11::repl.Session.App11.B)) ((advanced-features.md:157)))

// disable proxies and execute the module

val locator = Injector.NoProxies()
  .produce(module, GCMode.NoGC)
  .unsafeGet()
// locator: izumi.fundamentals.platform.functional.package.Identity[izumi.distage.model.Locator] = izumi.distage.LocatorDefaultImpl@60bdef7d

locator.get[A].b eq locator.get[B]
// res12: Boolean = true
locator.get[B].a eq locator.get[A]
// res13: Boolean = true
locator.get[C].c eq locator.get[C]
// res14: Boolean = true

The proxy generation via cglib is enabled by default, because in scenarios with extreme late-binding cycles can emerge unexpectedly, out of control of the origin module.

Note: Currently a limitation applies to by-names - ALL dependencies of a class engaged in a by-name circular dependency must be by-name, otherwise distage will revert to generating proxies.

Auto-Sets

AutoSet Planner Hooks can traverse the plan and collect all future objects that match a predicate.

Using Auto-Sets you can e.g. collect all AutoCloseable classes and .close() them after the application has finished work. NOTE: please use Resource bindings for real lifecycle, this is just an example.

import distage.{BootstrapModuleDef, ModuleDef, Injector, GCMode}
import izumi.distage.model.planning.PlanningHook
import izumi.distage.planning.AutoSetHook

class PrintResource(name: String) {
  def start(): Unit = println(s"$name started")
  def stop(): Unit = println(s"$name stopped")
}

class A extends PrintResource("A")
class B(val a: A) extends PrintResource("B")
class C(val b: B) extends PrintResource("C")

val bootstrapModule = new BootstrapModuleDef {
  many[PlanningHook]
    .add(new AutoSetHook[PrintResource, PrintResource](identity))
}
// bootstrapModule: AnyRef with BootstrapModuleDef = Module(many[{type.scala.collection.immutable.Set[=PlanningHook]}] ((advanced-features.md:207)), many[{type.scala.collection.immutable.Set[=PlanningHook]}].add[{type.izumi.distage.planning.AutoSetHook[=Session::App15::PrintResource,=Session::App15::PrintResource]}].from(call(izumi.distage.model.definition.dsl.ModuleDefDSL$SetDSLBase$$Lambda$17598/0x000000084417d840@28f5d68b(): izumi.distage.planning.AutoSetHook[=Session::App15::PrintResource,=Session::App15::PrintResource])) ((advanced-features.md:208)))

val appModule = new ModuleDef {
  make[A]
  make[B]
  make[C]
}
// appModule: AnyRef with ModuleDef = Module(make[{type.repl.Session::repl.Session.App15::repl.Session.App15.A}].from(call(<function1>(): repl.Session::repl.Session.App15::repl.Session.App15.A)) ((advanced-features.md:213)), make[{type.repl.Session::repl.Session.App15::repl.Session.App15.C}].from(call(<function1>(repl.Session::repl.Session.App15::repl.Session.App15.B): repl.Session::repl.Session.App15::repl.Session.App15.C)) ((advanced-features.md:215)), make[{type.repl.Session::repl.Session.App15::repl.Session.App15.B}].from(call(<function1>(repl.Session::repl.Session.App15::repl.Session.App15.A): repl.Session::repl.Session.App15::repl.Session.App15.B)) ((advanced-features.md:214)))

val resources = Injector(bootstrapModule)
  .produce(appModule, GCMode.NoGC)
  .use(_.get[Set[PrintResource]])
// resources: izumi.fundamentals.platform.functional.package.Identity[Set[PrintResource]] = ListSet(repl.Session$App15$A@7d3409dd, repl.Session$App15$B@6c9f2d17, repl.Session$App15$C@28f83c3e)

resources.foreach(_.start())
// A started
// B started
// C started
resources.toSeq.reverse.foreach(_.stop())
// C stopped
// B stopped
// A stopped

Calling .foreach on an auto-set is safe; the actions will be executed in order of dependencies. Auto-Sets preserve ordering, they use ListSet under the hood, unlike user-defined Sets. e.g. If C depends on B depends on A, autoset order is: A, B, C, to start call: A, B, C, to close call: C, B, A. When you use auto-sets for finalization, you must .reverse the autoset.

Note: Auto-Sets are NOT subject to Garbage Collection, they are assembled after garbage collection is done, as such they can’t contain garbage by construction. Because of that they also cannot be used as GC Roots.

See also: same concept in MacWire

Weak Sets

Set bindings can contain weak references. References designated as weak will be retained only if there are other dependencies on the referred bindings, NOT if there’s a dependency only on the entire Set.

Example:

import distage._

sealed trait Elem

final case class Strong() extends Elem {
  println("Strong constructed")
}

final case class Weak() extends Elem {
  println("Weak constructed")
}

val module = new ModuleDef {
  make[Strong]
  make[Weak]
  
  many[Elem]
    .ref[Strong]
    .weak[Weak]
}
// module: AnyRef with ModuleDef = Module(many[{type.scala.collection.immutable.Set[=Session::App18::Elem]}] ((advanced-features.md:256)), make[{type.repl.Session::repl.Session.App18::repl.Session.App18.Strong}].from(call(<function1>(): repl.Session::repl.Session.App18::repl.Session.App18.Strong)) ((advanced-features.md:253)), many[{type.scala.collection.immutable.Set[=Session::App18::Elem]}].add[{type.repl.Session::repl.Session.App18::repl.Session.App18.Strong}].from(using[{type.repl.Session::repl.Session.App18::repl.Session.App18.Strong}: repl.Session::repl.Session.App18::repl.Session.App18.Strong]) ((advanced-features.md:257)), many[{type.scala.collection.immutable.Set[=Session::App18::Elem]}].add[{type.repl.Session::repl.Session.App18::repl.Session.App18.Weak}].from(weak[{type.repl.Session::repl.Session.App18::repl.Session.App18.Weak}]) ((advanced-features.md:258)), make[{type.repl.Session::repl.Session.App18::repl.Session.App18.Weak}].from(call(<function1>(): repl.Session::repl.Session.App18::repl.Session.App18.Weak)) ((advanced-features.md:254)))

// Designate Set[Elem] as the garbage collection root,
// everything that Set[Elem] does not strongly depend on will be garbage collected
// and will not be constructed. 

val roots = Set[DIKey](DIKey.get[Set[Elem]])
// roots: Set[DIKey] = Set({type.scala.collection.immutable.Set[=Session::App18::Elem]})

val objects = Injector().produce(PlannerInput(module, roots)).unsafeGet()
// Strong constructed
// objects: izumi.fundamentals.platform.functional.package.Identity[Locator] = izumi.distage.LocatorDefaultImpl@33045b0

// Strong is around

objects.find[Strong]
// res19: Option[Strong] = Some(Strong())

// Weak is not

objects.find[Strong]
// res20: Option[Strong] = Some(Strong())

// There's only Strong in the Set

objects.get[Set[Elem]]
// res21: Set[Elem] = Set(Strong())

The Weak class was not required by any dependency of Set[Elem], so it was pruned. The Strong class remained, because the reference to it was strong, so it was counted as a dependency of Set[Elem].

If we change Strong to depend on the Weak, then Weak will be retained:

final class Strong(weak: Weak) extends Elem {
  println("Strong constructed")
}

val objects = Injector().produce(PlannerInput(module, roots)).unsafeGet()
// Weak constructed
// Strong constructed
// objects: izumi.fundamentals.platform.functional.package.Identity[Locator] = izumi.distage.LocatorDefaultImpl@3e0dec53

// Weak is around

objects.find[Weak]
// res23: Option[Weak] = Some(repl.Session$App22$Weak@3daf3701)

// both Strong and Weak are in the Set

objects.get[Set[Elem]]
// res24: Set[Elem] = Set(repl.Session$App22$Weak@3daf3701, repl.Session$App22$Strong@432e6e4b)

Inner Classes and Path-Dependent Types

Path-dependent types with a value prefix will be instantiated normally:

import distage.{GCMode, ModuleDef, Injector}

class Path {
  class A
}
val path = new Path
// path: Path = repl.Session$App25$Path@2c3ff566

val module = new ModuleDef {
  make[path.A]
}
// module: AnyRef with ModuleDef = Module(make[{type.repl.Session.App25.path::repl.Session.App25.Path.A}].from(call(<function1>(): repl.Session.App25.path::repl.Session.App25.Path.A)) ((advanced-features.md:342)))

Injector()
  .produce(module, GCMode.NoGC)
  .use(_.get[path.A])
// res26: izumi.fundamentals.platform.functional.package.Identity[path.A] = repl.Session$App25$Path$A@1affd638

Since version 0.10, support for path-dependent types with a non-value (type) prefix hasn’t reimplemented after a rewrite of the internals, see issue: https://github.com/7mind/izumi/issues/764

Depending on Locator

Objects can depend on the outer object graph that contains them (Locator), by including a LocatorRef parameter:

import distage.{ModuleDef, LocatorRef, Injector, GCMode}

class A(
  objects: LocatorRef
) {
  def c = objects.get.get[C]
}
class B
class C

val module = new ModuleDef {
  make[A]
  make[B]
  make[C]
}
// module: AnyRef with ModuleDef = Module(make[{type.repl.Session::repl.Session.App27::repl.Session.App27.B}].from(call(<function1>(): repl.Session::repl.Session.App27::repl.Session.App27.B)) ((advanced-features.md:375)), make[{type.repl.Session::repl.Session.App27::repl.Session.App27.C}].from(call(<function1>(): repl.Session::repl.Session.App27::repl.Session.App27.C)) ((advanced-features.md:376)), make[{type.repl.Session::repl.Session.App27::repl.Session.App27.A}].from(call(<function1>(izumi.distage.model.recursive.LocatorRef): repl.Session::repl.Session.App27::repl.Session.App27.A)) ((advanced-features.md:374)))

val objects = Injector().produce(module, GCMode.NoGC).unsafeGet()
// objects: izumi.fundamentals.platform.functional.package.Identity[izumi.distage.model.Locator] = izumi.distage.LocatorDefaultImpl@23648f8f

// A took C from the object graph

objects.get[A].c
// res28: C = repl.Session$App27$C@6d8d3374

// this C is the same C as in this `objects` value

val thisC = objects.get[C]
// thisC: C = repl.Session$App27$C@6d8d3374
val thatC = objects.get[A].c
// thatC: C = repl.Session$App27$C@6d8d3374

assert(thisC == thatC)

Locator contains metadata about the plan and the bindings from which it was ultimately created:

import distage.{OrderedPlan, ModuleBase}

// Plan that created this locator (after GC)

val plan: OrderedPlan = objects.plan
// plan: OrderedPlan = {type.LocatorRef} (advanced-features.md:374) := import {type.izumi.distage.model.recursive.LocatorRef} // required for {type.Session::App27::A}
// {type.PlannerInput} (InjectorDefaultImpl.scala:63) := value izumi.distage.model.PlannerInput#-1998705088
// {type.InjectorFactory} (InjectorDefaultImpl.scala:64) := value distage.Injector$#1659916447
// {type.Session::App27::B} (advanced-features.md:375) := call(<function1>(): Session::App27::B) {}
// {type.BootstrapModule} (InjectorDefaultImpl.scala:65) := value izumi.distage.model.definition.BootstrapContextModule$$anon$1#-1104045937
// {type.Session::App27::C} (advanced-features.md:376) := call(<function1>(): Session::App27::C) {}
// {type.Bootloader} (InjectorDefaultImpl.scala:66) := call(izumi.distage.InjectorDefaultImpl$$anon$1$$Lambda$16574/0x0000000843de1840@21404f9c(BootstrapModule, PlannerInput, InjectorFactory): Bootloader) {
//   arg bootstrapModule: BootstrapModule = lookup({type.BootstrapModule})
//   arg input: PlannerInput = lookup({type.PlannerInput})
//   arg injectorFactory: InjectorFactory = lookup({type.InjectorFactory})
// }
// {type.Session::App27::A} (advanced-features.md:374) := call(<function1>(LocatorRef): Session::App27::A) {
//   arg objects: LocatorRef = lookup({type.LocatorRef})
// }

// Bindings from which the Plan was built (after GC)

val bindings: ModuleBase = plan.definition
// bindings: ModuleBase = Module(make[{type.izumi.distage.model.PlannerInput}].from(value(PlannerInput(Module(make[{type.repl.Session::repl.Session.App27::repl.Session.App27.B}].from(call(<function1>(): repl.Session::repl.Session.App27::repl.Session.App27.B)) ((advanced-features.md:375)), make[{type.repl.Session::repl.Session.App27::repl.Session.App27.C}].from(call(<function1>(): repl.Session::repl.Session.App27::repl.Session.App27.C)) ((advanced-features.md:376)), make[{type.repl.Session::repl.Session.App27::repl.Session.App27.A}].from(call(<function1>(izumi.distage.model.recursive.LocatorRef): repl.Session::repl.Session.App27::repl.Session.App27.A)) ((advanced-features.md:374))),NoGC): izumi.distage.model.PlannerInput)) ((InjectorDefaultImpl.scala:63)), make[{type.repl.Session::repl.Session.App27::repl.Session.App27.A}].from(call(<function1>(izumi.distage.model.recursive.LocatorRef): repl.Session::repl.Session.App27::repl.Session.App27.A)) ((advanced-features.md:374)), make[{type.repl.Session::repl.Session.App27::repl.Session.App27.C}].from(call(<function1>(): repl.Session::repl.Session.App27::repl.Session.App27.C)) ((advanced-features.md:376)), make[{type.repl.Session::repl.Session.App27::repl.Session.App27.B}].from(call(<function1>(): repl.Session::repl.Session.App27::repl.Session.App27.B)) ((advanced-features.md:375)), make[{type.izumi.distage.InjectorFactory}].from(value(distage.Injector$@62f0509f: izumi.distage.InjectorFactory)) ((InjectorDefaultImpl.scala:64)), make[{type.izumi.distage.model.definition.BootstrapModule}].from(value(Module(many[{type.scala.collection.immutable.Set[=PlanningObserver]}] ((BootstrapLocator.scala:129)), make[{type.izumi.distage.model.provisioning.strategies.ResourceStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16420/0x0000000843d4d040@541423a3(): izumi.distage.provisioning.strategies.ResourceStrategyDefaultImpl)) ((BootstrapLocator.scala:125)), make[{type.izumi.distage.model.definition.BootstrapModule}].from(value(Module(many[{type.scala.collection.immutable.Set[=PlanningObserver]}] ((BootstrapLocator.scala:129)), make[{type.izumi.distage.model.provisioning.strategies.ResourceStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16420/0x0000000843d4d040@541423a3(): izumi.distage.provisioning.strategies.ResourceStrategyDefaultImpl)) ((BootstrapLocator.scala:125)), make[{type.izumi.distage.model.planning.PlanMergingPolicy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16411/0x0000000843d32840@659102f6(izumi.distage.model.definition.Activation): izumi.distage.planning.PruningPlanMergingPolicyDefaultImpl)) ((BootstrapLocator.scala:116)), make[{type.izumi.distage.model.provisioning.strategies.ProxyStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16426/0x0000000843d59840@628ee13c(izumi.distage.model.provisioning.proxies.ProxyProvider, izumi.distage.model.reflection.MirrorProvider): izumi.distage.provisioning.strategies.ProxyStrategyDefaultImpl)) ((BootstrapLocator.scala:137)), make[{type.izumi.distage.model.provisioning.ProvisioningFailureInterceptor}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16422/0x0000000843d4e840@669c688a(): izumi.distage.model.provisioning.ProvisioningFailureInterceptor::izumi.distage.model.provisioning.ProvisioningFailureInterceptor.DefaultImpl)) ((BootstrapLocator.scala:127)), make[{type.izumi.distage.model.planning.PlanningHook}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16424/0x0000000843d58040@136056c1(scala.collection.immutable.Set[=PlanningHook]): izumi.distage.planning.PlanningHookAggregate)) ((BootstrapLocator.scala:133)), make[{type.izumi.distage.model.provisioning.strategies.ProviderStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16416/0x0000000843d4a040@7e0b70e9(): izumi.distage.provisioning.strategies.ProviderStrategyDefaultImpl)) ((BootstrapLocator.scala:121)), make[{type.izumi.distage.planning.BindingTranslator}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16425/0x0000000843d59040@6b99f915(izumi.distage.model.planning.PlanningHook): izumi.distage.planning.BindingTranslator::izumi.distage.planning.BindingTranslator.Impl)) ((BootstrapLocator.scala:135)), make[{type.izumi.distage.model.planning.DIGarbageCollector}].from(call(izumi.distage.model.providers.ProviderMagnet$$$Lambda$16409/0x0000000843d34040@6ec414d4(): izumi.distage.planning.gc.TracingDIGC)) ((BootstrapLocator.scala:113)), make[{type.izumi.distage.model.reflection.MirrorProvider}].from(value(izumi.distage.model.reflection.MirrorProvider$Impl$@1754bfa4: izumi.distage.model.reflection.MirrorProvider::izumi.distage.model.reflection.MirrorProvider.Impl)) ((BootstrapLocator.scala:112)), make[{type.izumi.distage.provisioning.ProvisionOperationVerifier}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16408/0x0000000843d35040@7f838193(izumi.distage.model.reflection.MirrorProvider): izumi.distage.provisioning.ProvisionOperationVerifier::izumi.distage.provisioning.ProvisionOperationVerifier.Default)) ((BootstrapLocator.scala:110)), make[{type.izumi.distage.model.planning.PlanAnalyzer}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16410/0x0000000843d33840@5a2a3ab2(): izumi.distage.planning.PlanAnalyzerDefaultImpl)) ((BootstrapLocator.scala:115)), make[{type.izumi.distage.model.Planner}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16414/0x0000000843d48840@7edf31b3(izumi.distage.model.planning.ForwardingRefResolver, izumi.distage.model.planning.SanityChecker, izumi.distage.model.planning.DIGarbageCollector, izumi.distage.model.planning.PlanningObserver, izumi.distage.model.planning.PlanMergingPolicy, izumi.distage.model.planning.PlanningHook, izumi.distage.planning.BindingTranslator, izumi.distage.model.planning.PlanAnalyzer, izumi.distage.model.reflection.MirrorProvider): izumi.distage.planning.PlannerDefaultImpl)) ((BootstrapLocator.scala:119)), make[{type.scala.Boolean@distage.init-proxies-asap}].from(value(true: scala.Boolean)) ((BootstrapLocator.scala:107)), make[{type.izumi.distage.model.planning.SanityChecker}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16413/0x0000000843d48040@3073f808(izumi.distage.model.planning.PlanAnalyzer): izumi.distage.planning.SanityCheckerDefaultImpl)) ((BootstrapLocator.scala:118)), make[{type.izumi.distage.model.provisioning.strategies.ImportStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16417/0x0000000843d4b040@539f688c(): izumi.distage.provisioning.strategies.ImportStrategyDefaultImpl)) ((BootstrapLocator.scala:122)), make[{type.izumi.distage.model.provisioning.proxies.ProxyProvider}].from(call(izumi.distage.bootstrap.CglibBootstrap$$anon$1$$Lambda$16427/0x0000000843d5a840@586b37e7(): izumi.distage.provisioning.strategies.cglib.CglibProxyProvider)) ((CglibBootstrap.scala:11)), make[{type.izumi.distage.model.planning.ForwardingRefResolver}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16412/0x0000000843d32040@5f3ec7f0(izumi.distage.model.planning.PlanAnalyzer, scala.Boolean): izumi.distage.planning.ForwardingRefResolverDefaultImpl)) ((BootstrapLocator.scala:117)), make[{type.izumi.distage.model.planning.PlanningObserver}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16423/0x0000000843d4f040@7022c7a7(scala.collection.immutable.Set[=PlanningObserver]): izumi.distage.planning.PlanningObserverAggregate)) ((BootstrapLocator.scala:132)), make[{type.izumi.distage.model.provisioning.strategies.SetStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16415/0x0000000843d49840@58510a27(): izumi.distage.provisioning.strategies.SetStrategyDefaultImpl)) ((BootstrapLocator.scala:120)), make[{type.izumi.distage.model.provisioning.strategies.InstanceStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16418/0x0000000843d4b840@5984dac5(): izumi.distage.provisioning.strategies.InstanceStrategyDefaultImpl)) ((BootstrapLocator.scala:123)), make[{type.izumi.distage.model.definition.Activation}].from(value(Activation(Map()): izumi.distage.model.definition.Activation)) ((BootstrapLocator.scala:108)), make[{type.izumi.distage.model.provisioning.strategies.EffectStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16419/0x0000000843d4c840@702c9742(): izumi.distage.provisioning.strategies.EffectStrategyDefaultImpl)) ((BootstrapLocator.scala:124)), make[{type.izumi.distage.model.provisioning.PlanInterpreter}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16421/0x0000000843d4e040@16d5691f(izumi.distage.model.provisioning.strategies.SetStrategy, izumi.distage.model.provisioning.strategies.ProxyStrategy, izumi.distage.model.provisioning.strategies.ProviderStrategy, izumi.distage.model.provisioning.strategies.ImportStrategy, izumi.distage.model.provisioning.strategies.InstanceStrategy, izumi.distage.model.provisioning.strategies.EffectStrategy, izumi.distage.model.provisioning.strategies.ResourceStrategy, izumi.distage.model.provisioning.ProvisioningFailureInterceptor, izumi.distage.provisioning.ProvisionOperationVerifier): izumi.distage.provisioning.PlanInterpreterDefaultRuntimeImpl)) ((BootstrapLocator.scala:126)), many[{type.scala.collection.immutable.Set[=PlanningHook]}] ((BootstrapLocator.scala:130))): izumi.distage.model.definition.BootstrapContextModule)) ((Injector.scala:57)), make[{type.izumi.distage.model.planning.PlanMergingPolicy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16411/0x0000000843d32840@659102f6(izumi.distage.model.definition.Activation): izumi.distage.planning.PruningPlanMergingPolicyDefaultImpl)) ((BootstrapLocator.scala:116)), make[{type.izumi.distage.model.provisioning.strategies.ProxyStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16426/0x0000000843d59840@628ee13c(izumi.distage.model.provisioning.proxies.ProxyProvider, izumi.distage.model.reflection.MirrorProvider): izumi.distage.provisioning.strategies.ProxyStrategyDefaultImpl)) ((BootstrapLocator.scala:137)), make[{type.izumi.distage.model.provisioning.ProvisioningFailureInterceptor}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16422/0x0000000843d4e840@669c688a(): izumi.distage.model.provisioning.ProvisioningFailureInterceptor::izumi.distage.model.provisioning.ProvisioningFailureInterceptor.DefaultImpl)) ((BootstrapLocator.scala:127)), make[{type.izumi.distage.model.planning.PlanningHook}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16424/0x0000000843d58040@136056c1(scala.collection.immutable.Set[=PlanningHook]): izumi.distage.planning.PlanningHookAggregate)) ((BootstrapLocator.scala:133)), make[{type.izumi.distage.model.provisioning.strategies.ProviderStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16416/0x0000000843d4a040@7e0b70e9(): izumi.distage.provisioning.strategies.ProviderStrategyDefaultImpl)) ((BootstrapLocator.scala:121)), make[{type.izumi.distage.planning.BindingTranslator}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16425/0x0000000843d59040@6b99f915(izumi.distage.model.planning.PlanningHook): izumi.distage.planning.BindingTranslator::izumi.distage.planning.BindingTranslator.Impl)) ((BootstrapLocator.scala:135)), make[{type.izumi.distage.model.planning.DIGarbageCollector}].from(call(izumi.distage.model.providers.ProviderMagnet$$$Lambda$16409/0x0000000843d34040@6ec414d4(): izumi.distage.planning.gc.TracingDIGC)) ((BootstrapLocator.scala:113)), make[{type.izumi.distage.model.reflection.MirrorProvider}].from(value(izumi.distage.model.reflection.MirrorProvider$Impl$@1754bfa4: izumi.distage.model.reflection.MirrorProvider::izumi.distage.model.reflection.MirrorProvider.Impl)) ((BootstrapLocator.scala:112)), make[{type.izumi.distage.provisioning.ProvisionOperationVerifier}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16408/0x0000000843d35040@7f838193(izumi.distage.model.reflection.MirrorProvider): izumi.distage.provisioning.ProvisionOperationVerifier::izumi.distage.provisioning.ProvisionOperationVerifier.Default)) ((BootstrapLocator.scala:110)), make[{type.izumi.distage.model.planning.PlanAnalyzer}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16410/0x0000000843d33840@5a2a3ab2(): izumi.distage.planning.PlanAnalyzerDefaultImpl)) ((BootstrapLocator.scala:115)), make[{type.izumi.distage.model.Planner}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16414/0x0000000843d48840@7edf31b3(izumi.distage.model.planning.ForwardingRefResolver, izumi.distage.model.planning.SanityChecker, izumi.distage.model.planning.DIGarbageCollector, izumi.distage.model.planning.PlanningObserver, izumi.distage.model.planning.PlanMergingPolicy, izumi.distage.model.planning.PlanningHook, izumi.distage.planning.BindingTranslator, izumi.distage.model.planning.PlanAnalyzer, izumi.distage.model.reflection.MirrorProvider): izumi.distage.planning.PlannerDefaultImpl)) ((BootstrapLocator.scala:119)), make[{type.scala.Boolean@distage.init-proxies-asap}].from(value(true: scala.Boolean)) ((BootstrapLocator.scala:107)), make[{type.izumi.distage.model.planning.SanityChecker}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16413/0x0000000843d48040@3073f808(izumi.distage.model.planning.PlanAnalyzer): izumi.distage.planning.SanityCheckerDefaultImpl)) ((BootstrapLocator.scala:118)), make[{type.izumi.distage.model.provisioning.strategies.ImportStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16417/0x0000000843d4b040@539f688c(): izumi.distage.provisioning.strategies.ImportStrategyDefaultImpl)) ((BootstrapLocator.scala:122)), make[{type.izumi.distage.model.provisioning.proxies.ProxyProvider}].from(call(izumi.distage.bootstrap.CglibBootstrap$$anon$1$$Lambda$16427/0x0000000843d5a840@586b37e7(): izumi.distage.provisioning.strategies.cglib.CglibProxyProvider)) ((CglibBootstrap.scala:11)), make[{type.izumi.distage.model.planning.ForwardingRefResolver}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16412/0x0000000843d32040@5f3ec7f0(izumi.distage.model.planning.PlanAnalyzer, scala.Boolean): izumi.distage.planning.ForwardingRefResolverDefaultImpl)) ((BootstrapLocator.scala:117)), make[{type.izumi.distage.model.planning.PlanningObserver}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16423/0x0000000843d4f040@7022c7a7(scala.collection.immutable.Set[=PlanningObserver]): izumi.distage.planning.PlanningObserverAggregate)) ((BootstrapLocator.scala:132)), make[{type.izumi.distage.model.provisioning.strategies.SetStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16415/0x0000000843d49840@58510a27(): izumi.distage.provisioning.strategies.SetStrategyDefaultImpl)) ((BootstrapLocator.scala:120)), make[{type.izumi.distage.model.provisioning.strategies.InstanceStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16418/0x0000000843d4b840@5984dac5(): izumi.distage.provisioning.strategies.InstanceStrategyDefaultImpl)) ((BootstrapLocator.scala:123)), make[{type.izumi.distage.model.definition.Activation}].from(value(Activation(Map()): izumi.distage.model.definition.Activation)) ((BootstrapLocator.scala:108)), make[{type.izumi.distage.model.provisioning.strategies.EffectStrategy}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16419/0x0000000843d4c840@702c9742(): izumi.distage.provisioning.strategies.EffectStrategyDefaultImpl)) ((BootstrapLocator.scala:124)), make[{type.izumi.distage.model.provisioning.PlanInterpreter}].from(call(izumi.distage.bootstrap.BootstrapLocator$$anon$3$$Lambda$16421/0x0000000843d4e040@16d5691f(izumi.distage.model.provisioning.strategies.SetStrategy, izumi.distage.model.provisioning.strategies.ProxyStrategy, izumi.distage.model.provisioning.strategies.ProviderStrategy, izumi.distage.model.provisioning.strategies.ImportStrategy, izumi.distage.model.provisioning.strategies.InstanceStrategy, izumi.distage.model.provisioning.strategies.EffectStrategy, izumi.distage.model.provisioning.strategies.ResourceStrategy, izumi.distage.model.provisioning.ProvisioningFailureInterceptor, izumi.distage.provisioning.ProvisionOperationVerifier): izumi.distage.provisioning.PlanInterpreterDefaultRuntimeImpl)) ((BootstrapLocator.scala:126)), many[{type.scala.collection.immutable.Set[=PlanningHook]}] ((BootstrapLocator.scala:130))): izumi.distage.model.definition.BootstrapModule)) ((InjectorDefaultImpl.scala:65)), make[{type.izumi.distage.model.recursive.Bootloader}].from(call(izumi.distage.InjectorDefaultImpl$$anon$1$$Lambda$16574/0x0000000843de1840@21404f9c(izumi.distage.model.definition.BootstrapModule, izumi.distage.model.PlannerInput, izumi.distage.InjectorFactory): izumi.distage.model.recursive.Bootloader)) ((InjectorDefaultImpl.scala:66)))

The plan and bindings in Locator are saved in the state they were AFTER Garbage Collection has been performed. Objects can request the original input via a PlannerInput parameter:

import distage.{DIKey, GCMode, ModuleDef, PlannerInput, Injector}

class InjectionInfo(val plannerInput: PlannerInput)

val module = new ModuleDef {
  make[InjectionInfo]
}
// module: AnyRef with ModuleDef = Module(make[{type.repl.Session::repl.Session.App30::repl.Session.App30.InjectionInfo}].from(call(<function1>(izumi.distage.model.PlannerInput): repl.Session::repl.Session.App30::repl.Session.App30.InjectionInfo)) ((advanced-features.md:420)))

val input = PlannerInput(module, GCMode(root = DIKey.get[InjectionInfo]))
// input: PlannerInput = PlannerInput(Module(make[{type.repl.Session::repl.Session.App30::repl.Session.App30.InjectionInfo}].from(call(<function1>(izumi.distage.model.PlannerInput): repl.Session::repl.Session.App30::repl.Session.App30.InjectionInfo)) ((advanced-features.md:420))),GCRoots(Set({type.repl.Session::repl.Session.App30::repl.Session.App30.InjectionInfo})))

val injectionInfo = Injector().produce(input).unsafeGet().get[InjectionInfo]
// injectionInfo: InjectionInfo = repl.Session$App30$InjectionInfo@2d2ae7c7

// the PlannerInput in `InjectionInfo` is the same as `input`

assert(injectionInfo.plannerInput == input)

Bootloader is another summonable parameter that contains the above information in aggregate and lets you create another object graph from the same inputs as the current or with alterations.