title: Warning: Type safety: Unchecked cast from Object to PK
body: <p>How can I remove the warning from "<code>id = (PK) m.invoke(obj, (Object []) null);</code>"</p>
  
  <pre><code>    private PK getId(T obj) {
      PK id = null;
      for (Field f : type.getDeclaredFields()) {
          if (f.getAnnotation(Id.class) != null) {
              String name = f.getName();
              String method = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
              try {
                  Method m = type.getDeclaredMethod(method, (Class&lt;?&gt;) null);
                  id = (PK) m.invoke(obj, (Object []) null);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
      return id;
  }
  </code></pre>