title: ClassCastException with generic varargs?
body: <p>I have a generic interface</p>
  
  <pre><code>{
  void evaluate( TYPE... things );
  }
  </code></pre>
  
  <p>I have a generic method with the signature</p>
  
  <pre><code>&lt;TYPE&gt; void genericmethod( INTERFACE&lt;TYPE&gt; interfase, TYPE thing )
  {
  //the following line throws the ClassCastException
  interfase.evaluate( thing );
  }
  </code></pre>
  
  <p>PCard is a name in my project.</p>
  
  <p>So the call in the end is</p>
  
  <pre><code>INTERFACE&lt;PCard&gt; interfase = new WorkingImplementation&lt;PCard&gt;();
  PCard pcard = new PCard();
  </code></pre>
  
  <p>this seems to throw a ClassCastException in the genericmethod, when it tries to call turn the single pcard into a varargs array.</p>
  
  <pre><code>genericmethod( interfase, pcard );
  </code></pre>
  
  <p>The problem is relieved when there is no call to a genericmethod and you just call the interface directly.</p>
  
  <pre><code>interfase.evaluate( pcard );
  </code></pre>
  
  <p>What causes the Exception (internally)?     (my personal guess is java is overwhelmed)</p>
  
  <p>the Exception message:</p>
  
  <p>java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Llib.cardgame.CG$PCard; ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; [Llib.cardgame.CG$PCard; is in unnamed module of loader 'app')</p>