title: javac error: inconvertible types with generics?
body: <p>There are several other SO questions talking about generics compiling OK w/ Eclipse's compiler but not javac (i.e. <a href="https://stackoverflow.com/q/4133800/587642">Java: Generics handled differenlty in Eclipse and javac</a> and <a href="https://stackoverflow.com/q/2858799/587642">Generics compiles and runs in Eclipse, but doesn&#39;t compile in javac</a>) -- however this looks like a slightly different one.</p>
  
  <p>I have an <code>enum</code> class:</p>
  
  <pre><code>public class LogEvent {
     public enum Type {
         // ... values here ...
     }
     ...
  }
  </code></pre>
  
  <p>and I have another class with a method that takes in arbitrary objects of types descended from <code>Enum</code>:</p>
  
  <pre><code>@Override public &lt;E extends Enum&lt;E&gt;&gt; void postEvent(
      Context context, E code, Object additionalData) 
  {
      if (code instanceof LogEvent.Type)
      {
          LogEvent.Type scode = (LogEvent.Type)code;
      ...
  </code></pre>
  
  <p>This works fine in Eclipse, but when I do a clean built with <code>ant</code>, I am getting a pair of errors, one on the <code>instanceof</code> line, the other on the casting line:</p>
  
  <pre><code>443: inconvertible types
      [javac] found   : E
      [javac] required: mypackage.LogEvent.Type
      [javac]         if (code instanceof LogEvent.Type)
      [javac]             ^
  
  445: inconvertible types
      [javac] found   : E
      [javac] required: com.dekaresearch.tools.espdf.LogEvent.Type
      [javac]             LogEvent.Type scode = (LogEvent.Type)code;
      [javac]                                                  ^
  </code></pre>
  
  <p>Why does this happen, and how can I get around this problem so it will compile properly?</p>