title: The method is undefined for the type Class<capture#3-of ? extends Command>
body: <p>I have the abstract class</p>
  
  <pre><code>package main;
  
  public abstract class Command {
      protected final String key;
  
      public Command(String key) {
          this.key = key;
      }
  
      public abstract void function(String[] args);
      public abstract void help();
  }
  </code></pre>
  
  <p>But when I try to call the method <code>function(String[] args)</code>, albeit in a confusing and overly complicated way, problems ensue.</p>
  
  <hr />
  
  <pre><code>Class&lt;? extends Command&gt; x = (Class&lt;? extends Command&gt;) Class.forName(
          "main.Commands$" +
          String.valueOf(command.toCharArray()[0]).toUpperCase() +
          command.substring(1).toLowerCase()
  );
  
  x.function(args);
  </code></pre>
  
  <p>Gives me the error <code>The method function(String[]) is undefined for the type Class&lt;capture#3-of ? extends Command&gt;</code></p>
  
  <p>I alternatively tried the following:</p>
  
  <pre><code>Command x = (Command) Class.forName(
          "main.Commands$" +
          String.valueOf(command.toCharArray([0]).toUpperCase() +
          command.substring(1).toLowerCase()
  );
  </code></pre>
  
  <p>But that just gave me <code>Cannot cast from Class&lt;capture#1-of ?&gt; to Command</code>.</p>
  
  <p>I apologize in advance for my poor naming.</p>