title: Dependency Injection by type using generics - how does it work?
body: <p>Using Spring, I can get all beans of a certain type that are currently defined using this:</p>
  
  <pre><code>@Resource
  private List&lt;Foo&gt; allFoos;
  </code></pre>
  
  <p>How does Spring do this? I thought type information of generics was erased at runtime. So how does Spring know about the type <code>Foo</code> of the list and only inject dependencies of the correct type?</p>
  
  <p>To illustrate: I don't have a bean of type "List" that contains the other beans. Instead, Spring creates that list and adds all beans of the correct type (<code>Foo</code>) to this list and then injects that list.</p>