title: Why calling method with generic return on a generic class is considered unsafe by javac?
body: <p>Consider the following code:</p>
  
  <pre><code>public class Main {
      public static class NormalClass {
          public Class&lt;Integer&gt; method() {
              return Integer.class;
          }
      }
  
      public static class GenericClass&lt;T&gt; {
          public Class&lt;Integer&gt; method() {
              return Integer.class;
          }
      }
  
      public static void main(String... args) {
          NormalClass safeInstance = new NormalClass();
          Class&lt;Integer&gt; safeValue = safeInstance.method();
  
          GenericClass unsafeInstance = new GenericClass();
          Class&lt;Integer&gt; unsafeValue = unsafeInstance.method();
      }
  }
  </code></pre>
  
  <p>If I compile it with:</p>
  
  <pre><code>$ javac -Xlint:unchecked Main.java 
  </code></pre>
  
  <p>It returns:</p>
  
  <pre><code>Main.java:16: warning: [unchecked] unchecked conversion
          Class&lt;Integer&gt; unsafeValue = unsafeInstance.method();
                                                            ^
    required: Class&lt;Integer&gt;
    found:    Class
  1 warning
  </code></pre>
  
  <p>Please note that only the generic method is considered unsafe, even if no generic type is referenced on the return type.</p>
  
  <p>Is this a <code>javac</code> bug? Or there is a deeper reason for this I'm not taking into account?</p>