title: Java generic class's method is not applicable for the arguments passed
body: <p>I have a "strange" problem about Java generics.</p>
  
  <p>First I list my code:</p>
  
  <p><strong>Service.class</strong></p>
  
  <pre><code>package jse.generics.service;
  
  public interface Service {
  
  }
  </code></pre>
  
  <p><strong>ServiceProvider.class</strong></p>
  
  <pre><code>package jse.generics.service;
  
  public interface ServiceProvider&lt;T extends Service&gt; {
  
      public T getService();
  }
  </code></pre>
  
  <p><strong>ServiceProviderRegistry.class</strong></p>
  
  <pre><code>package jse.generics.service;
  
  import java.util.HashMap;
  import java.util.Map;
  
  public class ServiceProviderRegistry&lt;T extends Service&gt; {
  
       private Map&lt;Class&lt;T&gt;, ServiceProvider&lt;T&gt;&gt; map = new HashMap&lt;Class&lt;T&gt;, ServiceProvider&lt;T&gt;&gt;();
  
       public void register(Class&lt;T&gt; clazz, ServiceProvider&lt;T&gt; provider) {
            map.put(clazz, provider);
       }
  }
  </code></pre>
  
  <p><strong>FooService.class</strong></p>
  
  <pre><code>package jse.generics.service;
  
  public class FooService implements Service {
  
  }
  </code></pre>
  
  <p><strong>FooServiceProvider.class</strong></p>
  
  <pre><code>package jse.generics.service;
  
  public class FooServiceProvider implements ServiceProvider&lt;FooService&gt; {
  
       @Override
       public FooService getService() {
            return new FooService();
       }
  
  }
  </code></pre>
  
  <p><strong>ServiceTest.class</strong></p>
  
  <pre><code>package jse.generics.service;
  
  public class ServiceTest {
  
       /**
       * @param args
       */
       public static void main(String[] args) {
            ServiceProviderRegistry&lt;? extends Service&gt; registry = new ServiceProviderRegistry&lt;Service&gt;();
            registry.register(FooService.class, new FooServiceProvider());
       }
  
  }
  </code></pre>
  
  <p>In the ServiceTest class the compiler complaints that the registry.register method is not applicable for arguments passed to it.I really don't know why this happens. So I am looking forward to you guy's help to solve this problem.</p>