title: What type literal must I use to have CDI's Instance::select method work properly?
body: <p>Suppose I have an interface like this:</p>
  
  <pre><code>public interface Converter&lt;T&gt; { /*...*/ }
  </code></pre>
  
  <p>And suppose in a CDI environment I have successfully done this:</p>
  
  <pre><code>@Inject
  @Any
  private Instance&lt;Converter&lt;?&gt;&gt; converters;
  </code></pre>
  
  <p>(By "successfully" I mean that I can do the following and see several converters in the output, so beans are being discovered and supplied properly:</p>
  
  <pre><code>for (final Object o : converters) {
    System.out.println("*** converter: " + o);
  }
  </code></pre>
  
  <p>…so bean discovery is not the issue.)</p>
  
  <p>And now suppose that given <code>Integer.class</code>, I'd like to do this:</p>
  
  <pre><code>final TypeLiteral&lt;Converter&lt;Integer&gt;&gt; typeLiteral = new TypeLiteral&lt;Converter&lt;Integer&gt;&gt;(){};
  final Instance&lt;Converter&lt;Integer&gt;&gt; subInstance = converters.select(typeLiteral);
  final Converter&lt;Integer&gt; converter = subInstance.get();
  </code></pre>
  
  <p>This works fine.</p>
  
  <p>Now, in my actual code, <code>Integer.class</code> is passed in, as a value fulfilling a parameter declared as <code>Class&lt;T&gt;</code>, so what I really have is this:</p>
  
  <pre><code>final TypeLiteral&lt;Converter&lt;T&gt;&gt; typeLiteral = new TypeLiteral&lt;Converter&lt;T&gt;&gt;(){};
  final Instance&lt;Converter&lt;T&gt;&gt; subInstance = converters.select(typeLiteral);
  final Converter&lt;T&gt; converter = subInstance.get(); // this does not work
  </code></pre>
  
  <p>The <code>get()</code> call fails with a stack trace that starts with something that looks like the following:</p>
  
  <pre><code>org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001334: Unsatisfied dependencies for type Converter&lt;T&gt; with qualifiers @Any 
      at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:105)
  </code></pre>
  
  <p>What must I do to make this selection succeed?</p>
  
  <p>One thing I notice is that the stack is reporting that a <code>Converter&lt;T&gt;</code> cannot be found.  This looks suspicious: I would have expected it to talk in terms of <code>Converter&lt;Integer&gt;</code> instead, since the <code>T</code> "slot" is being "filled" with <code>Integer.class</code> at runtime, although, to be fair, I did indeed supply a <code>new TypeLiteral&lt;Converter&lt;T&gt;&gt;(){}</code>, not <code>new TypeLiteral&lt;Converter&lt;Integer&gt;&gt;(){}</code>.  </p>
  
  <p>Anyway, all this tells me that <code>TypeLiteral&lt;T&gt;</code> is using <code>T</code> as the type to look for, not the actual value "filling" the <code>T</code> "slot", and indeed, there is no converter declared as <code>implements Converter&lt;T&gt;</code>, only a converter declared as <code>implements Converter&lt;Integer&gt;</code>, and so I'm worried that what I'd like to do here is fundamentally impossible.</p>