title: Reflection IllegalArgumentException java
body: <p>What i am trying to do: get the value of the a reflected field named "f3" with the type "K". I would like to be able to use the value of f3 to reflect fields from within it. (edit)f3 is inside class b which is from a .jar file. (edit)</p>
  
  <p>All methods of getting the value that i try give the error: can not set K field f3 to java.lang.Class.</p>
  
  <p>Question: How can i get the value of the field <code>f3</code> (which has the type <code>K</code>) on the class <code>b</code> (which is a class loaded from an external jar) ?</p>
  
  <p>The following code throws an <code>IllegalArgumentException</code> :</p>
  
  <pre><code>Class instance = loadClass("b"); // simplified for readability
  Field fieldf3 = instance.getDeclaredField("f3");
  fieldf3.setAccessible(true);
  Object value = fieldf3.get(instance); //exception on this line.
  </code></pre>
  
  <p>StackTrace :</p>
  
  <pre><code>java.lang.IllegalArgumentException: Can not set K field b.f3 to java.lang.Class
      at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
      at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
      at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58)
      at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:36)
      at java.lang.reflect.Field.get(Field.java:387)
  </code></pre>