How does Corda 5 know which services to inject into a flow?

An interesting new feature in Corda 5 is the way that Services can be injected into Corda flows - as described here: Your First Flow - R3 Documentation

However, what’s not clear to me is: how does Corda know which flows to inject? Clearly, the CordaInject annotation is key here… but does Corda then look for (lateinit) vars with a specific name? Or is it looking for types? If the latter, what happens if two variables with the same type are present?

1 Like

Update: the injection engine, as expected, looks at the type of the variables that are annotated with CordaInject and injects the relevant service into the first one it finds. The other(s) is/are left uninitialised. This is probably a bug - we should warn or do something a bit more graceful. I’m sure it will be fixed for the beta!