title: Java Generics method parameter passing issue
body: <p>I have a problem about passing an parameter to a generic method. The code is the following:</p>
  
  <pre><code>public class View&lt;T extends View&lt;T,PM&gt;, PM extends Source&gt;  {
  
      protected PM source;
      protected EventManager&lt;T, PM&gt; eventManager;
  
      public View(PM s){
          this.source = s;
          eventManager = new EventManager&lt;T, PM&gt;();
          eventManager.setTarget(this); //error: "The method setTarget(T) in the type
                                //EventManager&lt;T,PM&gt; is not applicable for the arguments (View&lt;T,PM&gt;)"
  
          eventManager.setSource(s);
      }
  
      public void setBinding(Topic topic, IEventAction&lt;T,PM&gt; action){
          eventManager.setEventAction(topic, action)
      }
  
  }
  
  /** 
  * EventManager class has to remain completely generic. The type parameters cannot "extends"
  * anything because the EventManager is used also in other parts where T and S will have to be
  * classes other than "View" and "Source"
  */
  public class EventManager&lt;T, S&gt; {
      protected T target;
      protected S source;
      private LinkedHashMap&lt;Topic, IEventAction&lt;T, S&gt;&gt; eventActions;
  
      public EventManager(T target, S source){
          this.target = target;
          this.source = source;
      }
  
      public void setTarget(T target){
          this.target = target;
      }
  
      public void setSource(S source){
          this.source = source;
      }
  
      public void setEventAction(Topic topic, IEventAction&lt;T, S&gt; action) {
          //some code here ...
          omissis...
  
          eventActions.put(topic, action);
  
          omissis...
      }
  
      //other methods down here...omissis
  }
  </code></pre>
  
  <p>Eclipse gives me the error I put in comment on the line "eventManager.setTarget(this);". I can't understand why it gives me this error.
  Anyway, I found a solution (apparently) but I am not sure whether I did a "clean" or "dirty" thing. The solution is this:</p>
  
  <pre><code> eventManager.setTarget((T)this);
  </code></pre>
  
  <p>but it gives me a warning: "Type safety: Unchecked cast from View to T". To elimitate the warning I also put the following on top of the constructor method:</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  </code></pre>
  
  <p>It seems working but what is wrong? Do you have another "cleaner" solution (if it exists)? Do you think this is a "dirty" approach?</p>
  
  <p>Any soggestions are very welcome.</p>