title: Define a generic type with a class object at runtime
body: <p>Is it possible to declare the type of a generic using a class object? </p>
  
  <p>For instance, I would like to do something like this:</p>
  
  <pre><code>Class returnType = theMethod.getReturnType();
  
  AttributeComponent&lt;returnType&gt; attComponent;
  
  attComponent = new AttributeComponent&lt;returnType&gt;(returnType, attName);
  attributeComponents.put(methodName.substring(3), attComponent);
  </code></pre>
  
  <p>Now I know obviously this is incorrect, but is there a way to achieve this?</p>
  
  <p>EDIT: explaining a little bit</p>
  
  <p>I'm using reflection to go through all getters and then generate a UI element for each property (the AttributeComponent class, which has a JComponent element and a JLabel). I would like to use generics in order to create a getValue() method that would return an object of the property type.</p>